[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to store a sequence into an element ... and m
On 19.07.2020 21:14, Dr. Roger L Costello costello@xxxxxxxxx wrote:
Hi Folks,select="count($list)"/></xsl:message> other elements: select="count($document/List)"/></xsl:message>
in an element, along with other elements, such that I can pull the sequence out of the element and immediately operate on the sequence? If that can't be done, then what's the right way to do what I want to do? That expression will always return the number of "List" elements. If you use a schema and give that element a list datatype then I think that with schema-aware processing $document/List/data() would give you a list and you could of course count that list with e.g. count($document/List/data()) So the simplest example would be <xsl:import-schema> <xs:schema> <xs:element name="List" type="int-list"/> <xs:simpleType name="int-list"> <xs:list itemType="xs:integer"/> </xs:simpleType> </xs:schema> </xsl:import-schema> <xsl:template match="/" name="xsl:initial-template"> <xsl:variable name="list" select="(1, 2, 3)" as="xs:integer*" /> <xsl:message>count($list) = <xsl:value-of select="count($list)"/></xsl:message> <xsl:variable name="list-element" as="schema-element(List)"> <List xsl:validation="strict"> <xsl:sequence select="$list"/> </List> </xsl:variable> <xsl:message>count($list-element) = <xsl:value-of select="count($list-element)"/></xsl:message> <xsl:message>count($list-element/data()) = <xsl:value-of select="count($list-element/data())"/></xsl:message> <xsl:message select="$list-element instance of schema-element(List)"/> </xsl:template> you would need to write a more complex schema for the more complex sample you had I think, I am not sure whether you could use a schema type for that element inside other untyped elements.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|