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
j uSubject: recursion of wurfl document - variable does not populate on second iteration
Author: j u
Date: 08 Nov 2006 10:52 AM
Originally Posted: 08 Nov 2006 10:42 AM
Good afternoon,

I am writing an XSLT script that processes the WURFL document (found here: http://www.nusho.it/wurfl/dl.php?t=d&f=wurfl.zip) and returns plain text (for the purposes of this discussion I only return one ability's value - j2me_max_jar_size).

Looking at the WURFL document, certain capabilities can only be found if you get a <device>'s fall-back device as denoted by the fall_back attribute. To get this fall-back device I use recursion (and XSL:template which calls itself).

The first call to the template gives me the correct fall_back value (line 49-51). This fall_back value is used to get a <device> node from the document (line 66-68), and this node is then an argument to the recursive call to the template (line 71). If you trace through the transformation in Stylus studio you'll see that the <device> node that was passed into the recursive call also has a fall_back attribute ("opwv_v61_generic" in this example), but the template fails to extract this attribute's value into the variable "fallBackId" on line 49 as before.

Any ideas why this might be?
I'm a newbie... just started with XSLT this morning!

Thank you,
Juan M Uys


Unknownwurfl2.xsl
the XSLT transform file.

Postnext
j uSubject: recursion of wurfl document - variable does not populate on second iteration
Author: j u
Date: 08 Nov 2006 12:32 PM
Ok, I notice line 66 returns a result tree fragment (documentfragment) and the operations on this type of object is limited (see http://www.stylusstudio.com/w3c/xslt/N11774.htm).

I will figure out a work-around soon... maybe passing string values instead of nodes or fragments. Or maybe there's a totally different way of doing this.

Postnext
j uSubject: recursion of wurfl document - variable does not populate on second iteration
Author: j u
Date: 09 Nov 2006 04:56 AM
Originally Posted: 09 Nov 2006 04:40 AM
Excerpt from http://www.xml.com/pub/a/2002/04/10/xslt2.html :

<snip>
Death To the Result Tree Fragment!

In XSLT 1.0 the result tree fragment (RTF) type is like a node-set, but it is really a second-class citizen. An RTF is what you get whenever you use xsl:variable to construct a temporary tree. The problem is that you can't then use an XPath expression to access the innards of this tree, unless you use a vendor-specific extension function, usually called something like node-set(), to convert the RTF into a first-class node-set (consisting of one root node). The rationale for the RTF data type was that it would reduce implementation burden, but since almost all existing XSLT processors provide their own version of a node-set() extension function anyway, that consideration has become moot. In any case, the need to overcome this limitation has been clear for some time, as it is important to be able to break up complex transformations into sequences of simpler transformations.

If you haven't guessed already, XSLT 2.0 has shown RTFs the door. Now when you use xsl:variable to create a temporary tree, the value of that variable is a true node-set. Actually, in XPath 2.0 terms, it is a true node sequence, consisting of one document node, which is XPath 2.0's name for what XPath 1.0 called a "root node". With that sequence you can then use path expressions to drill down inside the tree, apply templates to it, and so on, just like you would with any other source document. With XSLT 2.0, there is no longer a need for the node-set() extension function.
</snip>

I've tried setting my Stylus Studio default XSLT processor to Saxon 8.7.3 (I'm fairly sure it supports XSLT 2.0 fully) and setting the XSL document to XSLT 2.0.

Will post results shortly.

Posttop
j uSubject: recursion of wurfl document - variable does not populate on second iteration
Author: j u
Date: 09 Nov 2006 06:27 AM
Porting to XSLT 2.0 will take too much of my (limited) time.

The solution has been under my nose all along: http://wurfl.sourceforge.net/xslt/index.php

 
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.