[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Computed Location Predicate

Subject: RE: Computed Location Predicate
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 2 Jan 2003 16:17:29 -0000
xs enumeration variable
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.