Subject: RE: [xsl] Computed Location Predicate From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Thu, 2 Jan 2003 16:17:29 -0000 |
> With Saxon 6.5.2, I tried many variations of the predicate > before final success with the following bit of the code, > which is within a for-each selecting > "/xs:schema/xs:complexType[<pulls the target > complexType>]/xs:restriction". > > <xsl:variable name="elementValue"> > <xsl:choose> > <xsl:when test="xs:enumeration"> > <xsl:variable name="enumPtr"> > <xsl:value-of > select="string-length($allValues) mod count(xs:enumeration) + 1"/> > </xsl:variable> An <xsl:variable> containing a single <xsl:value-of> is almost invariably bad coding. Write: <xsl:variable name="enumPtr" select="string-length($allValues) mod count(xs:enumeration) + 1"/> That way you get a value of type number, not of type result-tree-fragment. > > During the course of debugging, I used the the following without > success: > > <xsl:variable name="elementValue"> > <xsl:choose> > <xsl:when test="xs:enumeration"> > <xsl:value-of > select="xs:enumeration[number(string-length($allValues) mod > count(xs:enumeration) + 1)]/@value"/> > </xsl:when> > . I can't see any reason why this shouldn't work, it's equivalent to your working example. If you can supply a complete stylesheet and source document that shows the problem, I'll take a look at it for you. The number() function call here is redundant, its argument is already a number; but that shouldn't stop it working. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > > I understand that my problems with (many) earlier versions > were due to the processor's inability to distinguish the > predicate as a number rather than a non-number and therefore > a boolean. But why does the processor differentiate between > casting a variable to a number, which works, and casting an > expression to a number, which does not work? > > Any suggestions? > > > > Richard Patchet > bTrade, Inc. > 2324 Gateway Drive > Irving, TX 75063 > 972-5802981 > www.bTrade.com > > 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] Computed Location Predica, Jeni Tennison | Thread | [xsl] joining the values of a tag, Mani Malarvannan |
RE: [xsl] selecting multiple attrib, Michael Kay | Date | [xsl] using wmlscript in xsl, Madhavi Thottempudi |
Month |