134 <!-- produce a list of namespace-prefix namespace pairs separated by newlines, in reverse order found in documents |
134 <!-- produce a list of namespace-prefix namespace pairs separated by newlines, in reverse order found in documents |
135 reverse order so we can try to use the first namespace prefix defined if it's available--> |
135 reverse order so we can try to use the first namespace prefix defined if it's available--> |
136 <xsl:variable name="linked" select="document(@href,.)/*"/> |
136 <xsl:variable name="linked" select="document(@href,.)/*"/> |
137 <xsl:for-each select="$linked"> |
137 <xsl:for-each select="$linked"> |
138 <xsl:apply-templates select="//*[(self::component or self::collection or self::package or self::layer) and @href]" mode="scan-for-namespaces"/> |
138 <xsl:apply-templates select="//*[(self::component or self::collection or self::package or self::layer) and @href]" mode="scan-for-namespaces"/> |
139 <xsl:for-each select="//namespace::* | @id-namespace"> |
139 <xsl:for-each select="//namespace::*[.!='http://www.w3.org/XML/1998/namespace'] | @id-namespace"> |
|
140 <!-- ignore XML namespace --> |
140 <xsl:value-of select="concat(name(),' ',.,'
')"/> |
141 <xsl:value-of select="concat(name(),' ',.,'
')"/> |
141 </xsl:for-each> |
142 </xsl:for-each> |
142 </xsl:for-each> |
143 </xsl:for-each> |
143 <xsl:if test="not($linked)"> |
144 <xsl:if test="not($linked)"> |
144 <xsl:message>Note: The link to <xsl:value-of select="@href"/> from <xsl:value-of select="concat(name(),' ',@id)"/> could not be resolved. Perhaps there's an error in the XML?</xsl:message> |
145 <xsl:message>Note: The link to <xsl:value-of select="@href"/> from <xsl:value-of select="concat(name(),' ',@id)"/> could not be resolved. Perhaps there's an error in the XML?</xsl:message> |
464 </xsl:message> |
465 </xsl:message> |
465 </xsl:if> |
466 </xsl:if> |
466 <xsl:variable name="prefix" select="name($namespaces[.=$ns])"/> |
467 <xsl:variable name="prefix" select="name($namespaces[.=$ns])"/> |
467 <xsl:attribute name="{name()}"> |
468 <xsl:attribute name="{name()}"> |
468 <xsl:choose> |
469 <xsl:choose> |
469 <xsl:when test="$prefix = 'id-namespace' or (not($namespaces[name()='id-namespace']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix --> |
470 <xsl:when test="$prefix = 'id-namespace' or $namespaces[name()='id-namespace']=$ns or (not($namespaces[name()='id-namespace']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix --> |
470 <xsl:when test="$prefix='' and contains(.,':')"> |
471 <xsl:when test="$prefix='' and contains(.,':')"> |
471 <!-- complex: copy id and copy namespace (namespace should be copied already)--> |
472 <!-- complex: copy id and copy namespace (namespace should be copied already)--> |
472 <xsl:value-of select="."/> |
473 <xsl:value-of select="."/> |
473 </xsl:when> |
474 </xsl:when> |
474 <xsl:when test="$prefix='' and $ns=$defaultns"/> <!-- no prefix and it's the default --> |
475 <xsl:when test="$prefix='' and $ns=$defaultns"/> <!-- no prefix and it's the default --> |