Subject: More namespace fun? From: "Pawson, David" <DPawson@xxxxxxxxxxx> Date: Fri, 10 Mar 2000 11:41:58 -0000 |
Just to see what the ns axis is all about... Sprinkle a few namespaces into an xml file, and run the following stylesheet using saxon. To find out why the prefix is useful, remove the exclude-result prefixes line :-) For the curious but lazy, I include a dummy file at the end. HTH DaveP <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns-test="http://ns1.com" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" xmlns:long-namespace="http://ns3.com" exclude-result-prefixes="ns1 ns2 long-namespace" > <!-- Try removing some or all of the list of namespaces in exclude-result-prefixes --> <xsl:output method="xml" indent="yes"/> <xsl:template match="*"> <tag>Namespace:<xsl:choose><xsl:when test="namespace-uri(.)"><xsl:value-of select="namespace-uri(.)"/> </xsl:when> <xsl:otherwise> Null namespace</xsl:otherwise> </xsl:choose> </tag> <tag>name: <xsl:value-of select="name(.)"/></tag> <tag>local-name: <xsl:value-of select="local-name(.)"/></tag> <tag>Content: <xsl:value-of select="text()"/></tag> <xsl:if test="./*"><xsl:apply-templates/></xsl:if> </xsl:template> </xsl:stylesheet> ==================== Test file. <?xml version='1.0'?> <!DOCTYPE ns1:ns-test [ <!ELEMENT ns1:ns-test (block)+> <!ATTLIST ns-test xmlns:ns1 CDATA #FIXED "http://ns1.com" > <!ELEMENT ns2:block (para)+> <!ATTLIST block xmlns:ns2 CDATA #FIXED "http://ns2.com" > <!ELEMENT para (#PCDATA)> <!ATTLIST para id ID #IMPLIED another CDATA #IMPLIED>]> <ns1:ns-test xmlns:ns1= "http://ns1.com"> <block> <para>Para in block 1, main document namespace </para> </block> <ns2:block xmlns:ns2="http://ns2.com"> <para>Para in block 2</para> </ns2:block> <ns3:block xmlns:ns3="http://ns3.com"> <long:para xmlns:long="A long namespace uri">Para in block 3</long:para> </ns3:block> </ns1:ns-test> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Canonical Result Nodes, Christopher R. Maden | Thread | Re: More namespace fun?, David Carlisle |
Re: Combining multiple documents (W, Eric van der Vlist | Date | Re: Dynamic Table Generation, nigel . byrnes |
Month |