I have a most vexing problem. I am writing a transform to create a
sample document from a schema. For fun, I thought I would randomize the
selection of items from enumerated lists. 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>
<xsl:value-of
select="xs:enumeration[number($enumPtr)]/@value"/>
</xsl:when>
.
.
.
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$elementValue"/>
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>
.
.
.
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$elementValue"/>
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