XML Version 1
The College
element is bound to the same namespace for both documents.
Whether or not the XML documents use a namespace-prefix or if they have different prefix values is irrelevant. They are "seen" by the XML processor as the same type of element and are addressed the same way through XPath, since they are bound to the same namespace.
The namespace-prefix used in an XPath statement does not have to match the namespace-prefix in the XML document (as it would be impossible to predict what namesapce-prefixes someone might choose to use). However, the namespace that it is bound to must match.
Both of your XML documents are equivalent. Whether or not the elements have a namaspece-prefix, the elements are bound to the same namespaces.
If you look at how they are declared and what they map to, in the first XML document:
<College Version="5.0"
xmlns:cidx="urn:abc:names:specification:col:schema:all:5:0"
xmlns="urn:abc:names:specification:col:schema:all:5:0">
declares an element named College
without a namespace-prefix that is bound to the namespace urn:abc:names:specification:col:schema:all:5:0
because of the declaration of the namespace without a namespace-prefix xmlns="urn:abc:names:specification:col:schema:all:5:0"
.
In the second example:
<ns1:College Version="5.0"
xmlns:ns1="urn:abc:names:specification:col:schema:all:5:0">
Declares an element named College
using a namespace-prefix which is bound to the namespace urn:abc:names:specification:col:schema:all:5:0
.
The descendant elements of those College
elements in both examples are bound to the same namespace as the College
element that defined what the namespace for the ns1
namespace-prefix in the first example, or the null namespace-prefix in the second example document.
Any XSLT and XPath addressing those elements should return the same results.
Your template match in your XSLT should not work for either documents, as College
is not a child of inboundData
.
You would either need to adjust it to:
b:inboundData/b:Root/a:College/*
or
b:inboundData//a:College/*
You can match elements by their local name, like
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="urn:abc:names:specification:col:schema:all:5:0"
xmlns:b="urn:college:names:ws:docexchange">
<xsl:template match="/">
<xsl:copy-of select="b:inboundData/*[local-name()='College']/*"/>
</xsl:template>
</xsl:stylesheet>