You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/09/25 16:06:06 UTC

DO NOT REPLY [Bug 23412] New: - cant get namespaces from attribute node

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23412>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23412

cant get namespaces from attribute node

           Summary: cant get namespaces from attribute node
           Product: XalanJ2
           Version: 2.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: davidhewitt@if.com


this worked in previous versions (2.4 and earlier):
where the attribute value in the following has a namespace prefix:
e.g. type="tns:AType" so $ns should have the full namespace
with namespace declareation much further up the tree

<xsl:for-each select="/some path/@some attribute" >
	<xsl:variable name="pre" select="substring-before(current(),':')" />
	<xsl:variable name="ns" select="namespace::*[name() = $pre]" />

        <!-- use $ns ie the full namespace for stuff... -->
</xsl:for-each>

you now need to use ../namespace::*[name() = $pre] and have the element as 
the "current" node to get at the list of namespaces

same in <xsl:for-each select="namespace::*"> ... if the cutrrent() node is an 
attribute.

e.g.
xml:

<sch:test xmlns:sch="mytestnamespace">
	<sch:item name="sch:test" />
</sch:test>



xslt:

<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:sch="mytestnamespace">
       
    <xsl:output method="text"/>

	<xsl:template match="/">
		<xsl:for-each select="/sch:test/sch:item/@name" >
			<xsl:variable name="pre" select="substring-before
(current(),':')" />

	<xsl:value-of select="concat(substring-before(current(),':'),' -
&gt; ', namespace::*[name() = $pre])" />

		
		</xsl:for-each>
	</xsl:template>
	


</xsl:stylesheet>