Re: [xsl] Getting the root namespace from the input document

Subject: Re: [xsl] Getting the root namespace from the input document
From: "bryan rasmussen" <rasmussen.bryan@xxxxxxxxx>
Date: Tue, 6 Feb 2007 13:13:15 +0100
Okay I have to say that xalan and xsltproc give the results I would
expect from an XSLT 1.0 processor (not expect as in asserting this is
what the standard says but just expect as in what I would predict
would be the result) and saxon 6 gives the result I would expect for
an XSLT 2.0 processor.

Now I guess the question is, as you indicated before, if the
expectation meets a standard requirement.
cheers,
Bryan Rasmussen

On 2/6/07, Florent Georges <darkman_spam@xxxxxxxx> wrote:
Here are the results on Xalan, xsltproc, Saxon 6 and Saxon 8:

~/tests$ xalan -XSL namespace-double.xsl -IN namespace-double.xml
<my:same xmlns:my="namespace-double.xsl" added="my:value">
  <my:other xmlns:my="other-uri" added="my:value"/>
</my:same>

~/tests$ xsltproc namespace-double.xsl namespace-double.xml
<my:same xmlns:my="namespace-double.xsl" added="my:value">
  <my:other xmlns:my="other-uri" added="my:value"/>
</my:same>

~/tests$ saxon namespace-double.xml namespace-double.xsl
Warning: at xsl:stylesheet on line 6 of namespace-double.xsl:
  Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
<my:same xmlns:my="namespace-double.xsl" added="my:value">
  <my:other xmlns:my="other-uri" added="my:value"/>
</my:same>

~/tests$ saxon6 namespace-double.xml namespace-double.xsl
Error at xsl:copy-of on line 15 of namespace-double.xsl:
  Cannot create two namespace nodes with the same name
Transformation failed: Run-time errors were reported

~/tests$

Regards,

--drkm


bryan rasmussen wrote:


> 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
>
>







___________________________________________________________________________
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