[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: "bryan rasmussen" <rasmussen.bryan@xxxxxxxxx>
Date: Tue, 6 Feb 2007 12:52:34 +0100
Re:  Getting the root namespace from the input document
Okay I haven't gone and checked but I would expect that some
processors would change the namespace to fit the copy-of namespace. At
any rate what were the outputs like? Did you have an output from the
processors that was illegal? If not, what did they do?

This seems like a useful transform to test a lot of processor outputs
on actually.
Cheers,
Bryan Rasmussen

On 2/6/07, Florent Georges <darkman_spam@xxxxxxxx> wrote:
Michael Kay wrote:

Hi

> There's also sometimes a theoretical risk that prefixes
> will be changed because XSLT 1.0 permits it

Yes, it is what I thought about.

> but mainstream processors all do the decent thing in
> straightforward cases.

  And that is why I use it.  But I'm not very comfortable
with the use of this "observable behaviour" without knowing
exactly how this happens (prefixes will be changed in
particular cases or not?).

  In XSLT 2.0, the transformation fails if you try to create
a namespace node whose the prefix is already bound to
another namespace URI.  I like that.  In XSLT 1.0, the
transformation succeed, your result is not correct and the
error will propagate further in the chain.

Mmh, before to post, I just wrote a little test. Input:

    <my:same xmlns:my="namespace-double.xsl">
      <my:other xmlns:my="other-uri"/>
    </my:same>

Stylesheet:

    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        xmlns:my="namespace-double.xsl"
        exclude-result-prefixes="exsl"
        version="1.0">

<xsl:output indent="yes" omit-xml-declaration="yes"/>

      <xsl:template match="*">
        <xsl:variable name="dummy-ns">
          <my:e/>
        </xsl:variable>
        <xsl:copy>
          <xsl:copy-of select="
             exsl:node-set($dummy-ns)/*/namespace::*"/>
          <xsl:attribute name="added">my:value</xsl:attribute>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>

      <xsl:template match="@*|node()" priority="-1">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>

</xsl:stylesheet>

  I tested it with Saxon 6, Saxon 8, Xalan and xsltproc.
Actually, Saxon 6 was the only one to generate an error:

    Error at xsl:copy-of on line 16 of namespace-double.xsl:
      Cannot create two namespace nodes with the same name
    Transformation failed: Run-time errors were reported

  I thought in this case an XSLT 1.0 processor will change
one of the prefixes and not generate an error, but I didn't
find the right verses in the XSLT 1.0 REC.  Does any one
know those verses?

  Furthemore, I thought Saxon 8 didn't throw an error
because it was in compatibility mode, but the transformation
succeed even with an XSLT 2.0 stylesheet.  It fails if we
use xsl:namespace to create the node, but not if we use
xsl:copy-of to copy it.  Again, I didn't find in the XSLT
2.0 REC the difference between xsl:namespace and xsl:copy-of
regarding the duplicate namespace node names.  Any pointer?

Regards,

--drkm
























___________________________________________________________________________ Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions
!
Profitez des connaissances, des opinions et des expiriences des internautes
sur Yahoo! Questions/Riponses
http://fr.answers.yahoo.com

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.