[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] advice on node-set fallback needed
Subject: RE: [xsl] advice on node-set fallback needed From: "Julian Reschke" <julian.reschke@xxxxxx> Date: Tue, 19 Aug 2003 15:30:28 +0200 |
Thanks! -- <green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760 > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Michael Kay > Sent: Tuesday, August 19, 2003 3:05 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] advice on node-set fallback needed > > > XSLT 1.0 allows you to specify version on the xsl:stylesheet element, or > xsl:version on a literal result element. Unfortunately there is no way > of scoping the version to less than a whole stylesheet module unless you > have a convenient LRE. This anomaly is fixed in 2.0, but that's too late > for you. Putting version="2.0" on xsl:value-of should be an error under > 1.0, unless there's a version="2.0" on the xsl:stylesheet, in which case > its pointless! > > Michael Kay > > > -----Original Message----- > > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > > Julian Reschke > > Sent: 19 August 2003 09:20 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: RE: [xsl] advice on node-set fallback needed > > > > > > Thanks Mike. > > > > > Are you saying MSXML4 gives you a compile-time error for a path > > > expression that misuses an RTF? > > > > Yes. > > > > > The XSLT 1.0 spec is very unspecific about which errors are > > > compile-time errors and which are run-time. The spec merely > > says that > > > this operation "is not permitted". But you should be able > > to get it to > > > compile by using forwards-compatible mode, which you can invoke by > > > setting version="2.0" (or any value other than 1.0). > > > > So I'm now trying: > > > > <xsl:choose> > > <xsl:when test="function-available('exsl:node-set')"> > > <xsl:text>exsl: </xsl:text><xsl:value-of > > select="name(exsl:node-set($test)/node())" /> > > </xsl:when> > > <xsl:when test="function-available('msxsl:node-set')"> > > <xsl:text>msxsl: </xsl:text><xsl:value-of > > select="name(msxsl:node-set($test)/node())" /> > > </xsl:when> > > <xsl:otherwise> > > <xsl:text>(none): </xsl:text><xsl:value-of > > version="2.0" select="name($test/node())" /> > > </xsl:otherwise> > > </xsl:choose> > > > > However this breaks execution in Saxon 6.5.3 and MSXML completely: > > > > (MSXML3 and MSXML4) > > > > Error occurred while compiling stylesheet 'test.xslt'. > > > > Code: 0x80004005 > > Attribute 'version' is invalid on 'xsl:value-of'. > > > > (Saxon) > > > > Attribute version is not allowed on this element > > Transformation failed: Failed to compile stylesheet. 1 error detected. > > > > > > Using xsl:version instead of version yields: > > > > (MSXML3) > > > > Works. > > > > (MSXML4) > > > > Error occurred while compiling stylesheet 'test.xslt'. > > > > Code: 0x80004005 > > Expression must evaluate to a node-set. > > > > name(-->$test<--/node()) > > > > (Saxon) > > > > Attribute xsl:version is not allowed on this element > > Transformation failed: Failed to compile stylesheet. 1 error detected. > > > > > > What *does* seem to work is setting version="2.0" on the > > stylesheet element itself. However I'm a bit concerned that > > this will instruct an XSLT 2.0 in a non-XSLT-1.0 compatible manner. > > > > However, this: > > > > <xsl:choose> > > <xsl:when test="function-available('exsl:node-set')"> > > <xsl:text>exsl: </xsl:text><xsl:value-of > > select="name(exsl:node-set($test)/node())" /> > > </xsl:when> > > <xsl:when test="function-available('msxsl:node-set')"> > > <xsl:text>msxsl: </xsl:text><xsl:value-of > > select="name(msxsl:node-set($test)/node())" /> > > </xsl:when> > > <xsl:when test="system-property('xsl:version') >= 2.0"> > > <xsl:text>(XSLT2.0): </xsl:text><xsl:value-of > > version="2.0" select="name($test/node())" /> > > </xsl:when> > > <xsl:otherwise> > > <xsl:text>no way</xsl:text> > > </xsl:otherwise> > > </xsl:choose> > > > > seems to work with all 1.0 processors I tried, and should > > also work on an XSLT-2.0 processor without exslt:node-set(), right? > > > > > The rules for what a 2.0 processor should do when given a > > stylesheet > > > that says version="1.0" have not fully stabilised, but the next > > > version of the spec is likely to say that the processor > > should give a > > > warning about possible incompatibilities, and then execute the > > > stylesheet in backwards-compatible mode. It should not > > disallow use of > > > 2.0 features just because the stylesheet says > > version="1.0". In this > > > case, however, your stylesheet is using a 2.0 feature so it > > should say > > > version="2.0". > > > > > > Michael Kay > > > > Thank for the help, > > > > Julian > > > > -- > > <green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760 > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] advice on node-set fallba, Michael Kay | Thread | [xsl] Group and sort by group eleme, Simerman, Joshua Mic |
RE: [xsl] How can I get XSLT to wri, Michael Kay | Date | [xsl] How to process attributes of , Dan Vint |
Month |
Keywords