[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

More namespace fun?

Subject: More namespace fun?
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Fri, 10 Mar 2000 11:41:58 -0000
axis namespace ns1 ns2
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.