> Dimitre, I am trying to avoid the overhead of markup. In matrices I
don't want the overhead that markup incurs. Instead, I want plain old
sequences. Liam talked about this in a post last week.
Great. Then just use arrays or maps. I was under the impression that you
wanted to **store** permanently the list and this is why you had to make it
part of an XML document.
So, the question is: how would the permanent storage representation of the
list/matrice data be chosen.
On Sun, Jul 19, 2020 at 3:21 PM Dr. Roger L Costello
costello(_at_)mitre(_dot_)org <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Michael, upon further reflection I realized that what you are saying is to
replace this markup:
<Document>
<Greeting>My List</Greeting>
<List><xsl:sequence select="$list" /></List>
<Ending>The End</Ending>
</Document>
with a map:
<xsl:variable name="Document" as="map(xs:string, item()*)">
<xsl:map>
<xsl:map-entry key="'Greeting'" select="('My List')"/>
<xsl:map-entry key="'List'" select="(1,2,3)"/>
<xsl:map-entry key="'Ending'" select="('The End')"/>
</xsl:map>
</xsl:variable>
My application will process the map rather than markup. Neat!
Dimitre, I am trying to avoid the overhead of markup. In matrices I don't
want the overhead that markup incurs. Instead, I want plain old sequences.
Liam talked about this in a post last week.
/Roger
-----Original Message-----
From: Dr. Roger L Costello costello(_at_)mitre(_dot_)org <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Sunday, July 19, 2020 5:26 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [EXT] Re: [xsl] How to store a sequence into an element ...
andmaintainthe sequence inside the element?
Hello Michael,
Ah, so I think what you are saying is that I could store the sequence in a
map and then overwrite the sequence that is in the map. Something like this:
<xsl:variable name="list" as="map(xs:string, xs:integer*)">
<xsl:map>
<xsl:map-entry key="'li'" select="(1,2,3)"/>
</xsl:map>
</xsl:variable>
... do some processing and then update the list ...
<xsl:variable name="list" select="map:put($list, 'li', (4,1,5))"/>
... do some more processing and then update the list ...
<xsl:variable name="list" select="map:put($list, 'li', (9,9,0))"/>
... do some more processing and then update the list ...
Right?
/Roger
From: Michael Kay mike(_at_)saxonica(_dot_)com <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Sunday, July 19, 2020 4:58 PM
To: xsl-list <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [EXT] Re: [xsl] How to store a sequence into an element ... and
maintainthe sequence inside the element?
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
mailto:costello(_at_)mitre(_dot_)org
<mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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
http://www.mulberrytech.com/xsl/xsl-list
http://lists.mulberrytech.com/unsub/xsl-list/673357 ()
--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--