XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Geoffrey NuttingSubject: make sequence II
Author: Geoffrey Nutting
Date: 19 Aug 2007 10:13 PM
Hi,

I'm trying to figure out how to construct sequences from lists, but don't seem to be able to light on the right tool. Along the way,I've run into a couple of other features whose implementation I was wondering about:

Basically, if I have a list
<fl><fid>fida</fid><fid>fidb</fid><fid>fidc</fid><fid>fidd</fid><fid>fide</fid></fl>
I would like to be able to generate the sequence:
('fida','fidb','fidc','fidd','fide')
i.e., a list of text values of each of the elements.

Along the way, I have come to wonder (not understand):
a) what is the purpose of xsl:sequence
b) does xsl:value of have a 'separator' attribute
c) does xsl:variable have an 'as' attribute
in Stylus Studio? (build 894k)
I became aware of several of these on the Saxon homepage, XSLT Elements

Thank you,

Jeff Nutting

Postnext
Tony LavinioSubject: make sequence II
Author: Tony Lavinio
Date: 20 Aug 2007 12:02 AM
>Basically, if I have a list
><fl><fid>fida</fid><fid>fidb</fid><fid>fidc</fid><fid>fidd</fid><fid>fide</fid></fl>
>I would like to be able to generate the sequence:
>('fida','fidb','fidc','fidd','fide')

/fl/fid/text() returns that sequence.

<xsl:value-of> evaluates each item as a string and concatenates
the results together into a single string.

<xsl:sequence> returns a sequence with each item separately. It's
kind of like xsl:copy-of.

Sequences are a feature of XSLT 2.0, which is implemented only in
the Saxon 8.x XSLT engine in Stylus Studio.

>Along the way, I have come to
>wonder (not understand):
>a) what is the purpose of xsl:sequence

See above. XSLT 2.0 only.

>b) does xsl:value-of of have a 'separator' attribute

XSLT 2.0 only. See http://www.w3.org/TR/xslt20/#value-of

>c) does xsl:variable have an 'as' attribute in Stylus Studio?
>(build 894k) I became aware of several of these on the Saxon
>homepage, XSLT Elements

XSLT 2.0 only. Again, you must switch to the Saxon 8.x XSLT
engine to use this.

Postnext
Geoffrey NuttingSubject: make sequence II
Author: Geoffrey Nutting
Date: 20 Aug 2007 03:25 PM
I tried to switch to the Saxon 8.9.x processor on my Processors tab:
screenshot enclosed;I'm still not sure whether I'm (accidentally) still using the built-in processor (& what processor that is).


Unknownss_saxon.rtf

Postnext
Tony LavinioSubject: make sequence II
Author: Tony Lavinio
Date: 20 Aug 2007 04:13 PM
That's right, and you also need to make sure you tell your XSLT
to use 2.0, like this:

<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

If you just set version="2.0" on the xsl:stylesheet (NOT the xml version!)
Stylus Studio will prompt you to switch to Saxon 8, so you really only
need to do one step.

If you don't set the stylesheet to version 2.0, you run in 1.0
compatibility mode, which runs mostly like a regular XSLT 1.0 engine.

Postnext
Geoffrey NuttingSubject: make sequence II
Author: Geoffrey Nutting
Date: 20 Aug 2007 06:45 PM
Hi,

Thanks to your comments, I got a test program to run reasonably smoothly

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<f>
<xsl:variable name="tempa">
<xsl:value-of select="'a1','a2','a3'"/>
</xsl:variable>

<xsl:variable name="tempb" as="item()*">
<xsl:sequence select="'c1','c2','c3'"/>
</xsl:variable>

<a><xsl:value-of select="$tempa[1]"/></a>
<b><xsl:value-of select="$tempb[1]"/></b>
<cp><xsl:copy /></cp>
<d><xsl:copy-of select="$tempb"/></d>
<all><xsl:value-of select="$tempb"/></all>
<xsl:variable name="tempc" as="item()*">
<xsl:sequence select="'c1','c2','c3'"/>
</xsl:variable>
<c><xsl:value-of select="$tempc[1]"/></c>
</f>
</xsl:template>

</xsl:stylesheet>

but when I put a separator attribute on the copy-of statement, it fails
with the message

at: file:///c:/film/film_ws/makseq80.xsl 17
java.lang.RuntimeException: Error: at xsl:copy-of on line 17 of file:///c:/film/film_ws/makseq80.xsl:
XTSE0090: Attribute @separator is not allowed on element <xsl:copy-of>

at com.exln.stylus.CSaxon8Driver.doProcessing(CSaxon8Driver.java:258)
at com.exln.stylus.CProcessorDriver.process(CProcessorDriver.java:111)
makseq80.xsl (17, 1)
Error: at xsl:copy-of on line 17 of file:///c:/film/film_ws/makseq80.xsl: XTSE0090: Attribute @separator is not allowed on element <xsl:copy-of>

believe I am using the Saxon 8.9.x processor, & that there is an optional separator attribute on it: what's the status of it in Stylus Studio?

Thanks,

Jeff Nutting

Postnext
Tony LavinioSubject: make sequence II
Author: Tony Lavinio
Date: 21 Aug 2007 10:47 AM
Where did you get the impression that separator was available on
xsl:copy-of?

xsl:copy-of copies nodes, not string values, so a separator there
wouldn't make sense.

Only xsl:value-of and xsl:attribute, both of which generate string
values from their content, support the separator attribute.

See http://www.w3.org/TR/xslt20/#schema-for-xslt

Postnext
Geoffrey NuttingSubject: make sequence II
Author: Geoffrey Nutting
Date: 21 Aug 2007 04:02 PM
OK,
FYI, I got the apparently outdated info from trolling the internet at this site

http://saxon.sourceforge.net/saxon7.5/xsl-elements.html#xsl:copy-of

What's the best place to start looking if I have a general series of questions like I've pitched at you recently & haven't been able to find or discern the correct answer forom the Stylus documentation? Up to date standards docs at....??

I don't mean in any way to diminish the value of the pointers you've given me

Thanks a lot,

Jeff Nutting

Posttop
Tony LavinioSubject: make sequence II
Author: Tony Lavinio
Date: 22 Aug 2007 02:01 PM
XSLT 2.0 standard
http://www.w3.org/TR/xslt20/

XPath 2.0 standard
http://www.w3.org/TR/xpath20/

Saxon current documentation:
http://www.saxonica.com/

You might also consider picking up the two books, XPath 2.0 and
XSLT 2.0, both authored by Michael Kay

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.