Subject: RE: [xsl] resolveQName and xpath-default-namespace From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 29 Sep 2004 11:47:06 +0100 |
Yes, that's the Saxon error. IIRC, I got the fix for this into the final build of Saxon 8.1 - try it again. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Joe Fawcett [mailto:joefawcett@xxxxxxxxxxx] > Sent: 29 September 2004 11:11 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] resolveQName and xpath-default-namespace > > Thanks Michael, I read your reply. This was a follow on, I > still don't > understand why: > resolve-QName($chap/@att-one, $doc) > doesn't resolve 'value' to {one.uri}value when $doc is used for the > resolving node as it has 'one' mapped to 'one.uri'. > Is that the Saxon error you meant? If so, fine, I just wanted > to make sure I > had understood properly how the function is supposed to work. > I didn't mean to criticise Saxon at all, it's a fantastic > product and it > looks like our company is going to buy the schema aware version too. > > > Thanks for all your help. > > Joe > > > >From: "Michael Kay" <mike@xxxxxxxxxxxx> > >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > >Subject: RE: [xsl] resolveQName and xpath-default-namespace > >Date: Wed, 29 Sep 2004 10:25:28 +0100 > > > >I replied to your original posting at > >http://p2p.wrox.com/topic.asp?TOPIC_ID=19710 Unfortunately > there is an > >error > >in the book here, and also an error in the Saxon implementation; more > >embarrassingly still, the two errors are different. This is > only partially > >excused by the fact that the spec was changed at some stage. > > > >The answer to your final question is yes: if an > xpath-default-namespace is > >in force, then there is no way to select elements in no > namespace. But you > >can reset it, for any region of the stylesheet, by putting > >xpath-default-namespace="" on any XSLT element. > > > >Michael Kay > > > > > > > > > -----Original Message----- > > > From: Joe Fawcett [mailto:joefawcett@xxxxxxxxxxx] > > > Sent: 29 September 2004 09:50 > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > > Subject: [xsl] resolveQName and xpath-default-namespace > > > > > > With source doc: > > > > > > <doc xmlns:one="one.uri" xmlns="default.uri"> > > > <chap xmlns="" att-one="text"> > > > <data-one>one:value</data-one> > > > <data-two>value</data-two> > > > </chap> > > > </doc> > > > > > > I tried the following stylesheet: > > > > > > > > > <xsl:stylesheet > > > version="2.0" > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > > xmlns:one="one.uri" > > > xmlns:def="default.uri"> > > > > > > <xsl:output method="text" indent="yes"/> > > > > > > <xsl:variable name="doc" select="/def:doc"/> > > > <xsl:variable name="chap" select="/def:doc/chap"/> > > > <xsl:variable name="data1" select="/def:doc/chap/data-one"/> > > > <xsl:variable name="data2" select="/def:doc/chap/data-two"/> > > > > > > <xsl:template match="/"> > > > <xsl:variable name="res0" > > > select="resolve-QName($chap/@att-one, $doc)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res0)"/>}<xsl:value-of > > > select="local-name-from-QName($res0)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res1" > > > select="resolve-QName($chap/@att-one, $chap)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res1)"/>}<xsl:value-of > > > select="local-name-from-QName($res1)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res2" > > > select="resolve-QName(string($data1), $data1)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res2)"/>}<xsl:value-of > > > select="local-name-from-QName($res2)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res3" > > > select="resolve-QName(string($data2), $data2)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res3)"/>}<xsl:value-of > > > select="local-name-from-QName($res3)"/><xsl:text>#xa;</xsl:text> > > > </xsl:template> > > > </xsl:stylesheet> > > > > > > > > > against the doc shown above. I get: > > > {}text > > > > > > {}text > > > > > > {one.uri}value > > > > > > {}value > > > > > > I don't understand why resolve-QName($chap/@att-one, $doc) > > > doesn't resolve > > > 'value' to {one.uri}value when $doc is used for the resolving > > > node as it has > > > 'one' mapped to 'one.uri'. > > > > > > then I tried adding xpath-default-namespace="default-uri" and > > > removing the > > > def: prefix from the variables declarations and the > > > stylesheet namespace > > > declaration. This led to an error indicating that > > > $chap/@att-one was an > > > empty sequence. I presume this is something to do with the > > > default namespace > > > being undeclared. The full stylesheet: > > > > > > > > > <xsl:stylesheet > > > version="2.0" > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > > xmlns:one="one.uri" > > > xpath-default-namespace="default.uri"> > > > > > > <xsl:output method="text" indent="yes"/> > > > > > > <xsl:variable name="doc" select="/doc"/> > > > <xsl:variable name="chap" select="/doc/chap"/> > > > <xsl:variable name="data1" select="/doc/chap/data-one"/> > > > <xsl:variable name="data2" select="/doc/chap/data-two"/> > > > > > > <xsl:template match="/"> > > > <xsl:variable name="res0" > > > select="resolve-QName($chap/@att-one, $doc)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res0)"/>}<xsl:value-of > > > select="local-name-from-QName($res0)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res1" > > > select="resolve-QName($chap/@att-one, $chap)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res1)"/>}<xsl:value-of > > > select="local-name-from-QName($res1)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res2" > > > select="resolve-QName(string($data1), $data1)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res2)"/>}<xsl:value-of > > > select="local-name-from-QName($res2)"/><xsl:text>#xa;</xsl:text> > > > <xsl:variable name="res3" > > > select="resolve-QName(string($data2), $data2)"/> > > > {<xsl:value-of > > > select="namespace-uri-from-QName($res3)"/>}<xsl:value-of > > > select="local-name-from-QName($res3)"/><xsl:text>#xa;</xsl:text> > > > </xsl:template> > > > > > > </xsl:stylesheet> > > > > > > > > > > > > This didn't work either, does that mean once I have used the > > > xpath-default-namespace I can't select this sort of element > > > (no namespace)? > > > > > > > > > I am using Saxon 8 basic. > > > > > > -- > > > > > > Joe > > > > > > PS (to Michael Kay - I tried posting to Saxon list at > > > SourceForge but was > > > not able to subscribe as I never received a confirmation email)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] resolveQName and xpath-de, Joe Fawcett | Thread | [xsl] how to Filter the log files, Shrivastava, Shrivas |
RE: [xsl] Unwanted added spaces in , Michael Kay | Date | RE: [xsl] how to Filter the log fil, Jarno.Elovirta |
Month |