Subject: RE: [xsl] comparisons between strings have changed since XPath 1.0 warning From: TGolshan@xxxxxxxxxxxx Date: Wed, 5 Oct 2005 08:56:05 -0700 |
Michael, Thanks for the explanation of why I am getting the error. I am using saxon7.7 and xsl:stylesheet version 1.0. I clearly need to upgrade my system and move fully to XSLT 2.0. Thanks again, troy "Michael Kay" <mike@xxxxxxxxxxxx> 10/05/2005 01:26 AM Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx To <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> cc Subject RE: [xsl] comparisons between strings have changed since XPath 1.0 warning > > I receive the below error message when I try to compile the > below XML. I > am using saxon7 Saoxn 7-point-what? Whatever the answer, you're way out of date: the current release is Saxon 8.5.1. Since the 2.0 specs have actually been evolving over several years, it's difficult to tell you what the spec was at the time your particular version came out. You haven't shown the <xsl:stylesheet> element. It may not make any difference on older releases, but the current spec is that if xsl:stylesheet specifies version="1.0" you get backwards compatible behavior in this area, if it specifies version 2.0 then the new rules are followed. Your expression here is comparing a result tree fragment (document node) to a string. In 1.0 (or 1.0 mode) both values are converted to numbers and compared numerically. In 2.0 mode, they are compared as strings. So in 1.0 mode '20'>'3', in 2.0 mode '20'<'3'. To ensure a numeric comparison under either version, write test="$webs > 3" (and use the current Saxon release). Looking at it more carefully, what is this construct trying to achieve: <xsl:variable name="webs"> <xsl:number value="count(WebExtra)"/> </xsl:variable> This evaluates count(WebExtra) giving a number (say 5), it then formats it using the default numeric format, which gives the string "5"; it then creates a result tree fragment containing a text node whose string value is "5" - all so that the value can be converted back to a number! Just write <xsl:variable name="webs" select="count(WebExtra)"/>. Michael Kay http://www.saxonica.com/ and can trace my error to > <xsl:when test="$webs > '3'"> > but I am not sure how to fix this. I found some info on the > oasis list > site, but nothing in the mulberry archives. > > Any help would be appreciated. Thanks in advance-troy > > > ***********************Error******************************** > Less-than and greater-than comparisons between strings have changed > since XPath 1.0 > > > ***********************XSL******************************** > > <xsl:if test="string-length(WebExtra) > 1"> > <xsl:variable name="webs"> > <xsl:number value="count(WebExtra)"/> > </xsl:variable> > <xsl:choose> > <xsl:when test="$webs > '3'"> > <xsl:result-document href="WebExtra.html"> > <xsl:for-each select="WebExtra"> > > <p><xsl:copy-of select=" > ABSTOC"/></p> > </xsl:for-each> > </xsl:result-document> > <a href="WebExtra.html"> > <img src=" > /common/images/doi_bookmark.gif" width="18" height="20" > alt="Web Extra" > class="hspace" border="0" align="absMiddle"/><xsl:value-of > select="'Web > Extras'"/> > </a> > </xsl:when> > <xsl:otherwise> > <xsl:for-each select="WebExtra"> > <p> <xsl:copy-of select="ABSTOC"/></p> > </xsl:for-each> > </xsl:otherwise> > </xsl:choose> > </xsl:if> > > ************************XML******************************* > > <Article> > <WebExtra> > <TITLE>My first title here</TITLE> > <ABSTOC>Web extra: Part I</ABSTOC> > </WebExtra> > <WebExtra> > <TITLE>My second title here</TITLE> > <ABSTOC>Web extra: Part II</ABSTOC> > </WebExtra> > > <!--Can have anywhere from 0 to 100 web extras listed--> > > </Article>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] comparisons between strin, Michael Kay | Thread | [xsl] Summing Time Durations Help, Kent Seegmiller |
Re: [xsl] Getting the data after an, Mukul Gandhi | Date | RE: [xsl] Wildcard problem, Michael Kay |
Month |