[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

Subject: Re: How to store a sequence into an element ... and maintain the sequence inside the element?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Jul 2020 20:57:52 -0000
Re:  How to store a sequence into an element ... and  m
That's the point Liam was making last week - XML is very text-oriented. When
you add a list of numbers to a document it gets serialized as a string. As
Martin says, you can turn it back into a sequence of numbers by validating
against a list type defined in a schema. But that's very limiting, which is
why XSLT 3.0 introduced maps and arrays.

Michael Kay
Saxonica

> On 19 Jul 2020, at 20:14, Dr. Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Folks,
>
> I created a sequence (1, 2, 3) as follows:
>
> <xsl:variable name="list" select="(1, 2, 3)" as="xs:integer*" />
>
> I checked that $list contains 3 integers:
>
> <xsl:message>count($list) = <xsl:value-of
select="count($list)"/></xsl:message>
>
> Sure enough, the output shows that there are 3 items:
>
> count($list) = 3
>
> Next, I want to store that sequence of integers in an element, along with
other elements:
>
> <xsl:variable name="document" as="element(Document)">
>    <Document>
>        <Greeting>My List</Greeting>
>        <List><xsl:sequence select="$list" /></List>
>        <Ending>The End</Ending>
>    </Document>
> </xsl:variable>
>
> Does the <List> element contain a sequence of 3 integers:
>
> <xsl:message>count($document/List) = <xsl:value-of
select="count($document/List)"/></xsl:message>
>
> Yikes! No it doesn't:
>
> count($document/List) = 1
>
> How to do what I want to do? That is, how to store the sequence of integers
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?
>
> Here is my XSLT program:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    version="3.0">
>
>    <xsl:template match="/">
>        <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="document" as="element(Document)">
>            <Document>
>                <Greeting>My List</Greeting>
>                <List><xsl:sequence select="$list" /></List>
>                <Ending>The End</Ending>
>            </Document>
>        </xsl:variable>
>        <xsl:message>count($document/List) = <xsl:value-of
select="count($document/List)"/></xsl:message>
>    </xsl:template>
> </xsl:stylesheet>
>
> /Roger

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.