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

Re: Getting the root namespace from the input document

Subject: Re: Getting the root namespace from the input document
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 5 Feb 2007 16:12:16 +0000
Re:  Getting the root namespace from the input document
On 2/5/07, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
On 2/5/07, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
> <xsl:template match="/">
>        <Metadata>
>                <xsl:copy-of select="namespace::node()"/>
>        </Metadata>
> </xsl:template>

I think Andrew means:

<xsl:template match="/manifest">
   <Metadata>
      <xsl:copy-of select="namespace::*"/>
   </Metadata>
</xsl:template>

I did, well spotted!


But namespace:: axis is deprecated in XSLT 2.0 (though, Saxon supports it)

That's interesting... wasn't aware of that.


If you are using XSLT 2.0, the following is perhaps a portable way:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:output method="xml" indent="yes" />

<xsl:template match="manifest">
  <xsl:variable name="x" select="." />
  <Metadata>
    <!-- create namespace declarations -->
    <xsl:for-each select="in-scope-prefixes($x)">
      <xsl:namespace name="{.}"><xsl:value-of
select="namespace-uri-for-prefix(., $x)" /></xsl:namespace>
    </xsl:for-each>

    <!-- do rest of things -->
  </Metadata>
</xsl:template>

</xsl:stylesheet>

That's really cool too. This is all news to me - I didn't think the prefixes were available to the XSLT processor...?

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-2011 All Rights Reserved.