[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

M.Kay XSLT book, p. 120 Curly braces question

Subject: M.Kay XSLT book, p. 120 Curly braces question
From: Gert Bultman <g.w.bultman@xxxxxxxxxxxxxx>
Date: Mon, 31 Jul 2000 09:53:26 +0000
xslt curly braces
On page 120 of his XSLT book, Michael Kay describes where the curly
braces construct can and cannot be used. In the example at the top of
the page he describes a situation where it cannot be used, but fails to
give an alternative solution. 
I am at the moment facing a similar problem, where I would like to use a
variable or parameter as part of an XPath expression. However, whereas I
can use variables in constructions such as
$doc/FeatureSet[$i]/Feature[$j], where $doc is a nodeset generated by 

<xsl:variable name="doc" select="document(@FeatureFile)"/>

I cannot use a construction like $doc//$mypointer, where $mypointer has
the value 'FeatureSet[2]/Feature[4]'. (saxon & xt both balk at the
second $ sign in the expression)

To illustrate my point I'll include my xml and xsl fragments:

XML:

In my xml file which describes my data, I want to include a reference to
the original data that was used in the calculation. Since that data,
too, is stored in an XML file, I would ideally store an xpointer in one
of the attributes, and use that directly in my XSL stylesheet. 
Failing to do so, I then started using an additional attribute for
storing the counters. These I can use easily in my stylesheet, as the
example shows. 

<EventNode Id='1' FeatureFile='f1.xml' Fid="1.2"
FeatureId='FeatureSet[1]/Feature[2]' EventIn='CONT' EventOut='CONT'/>
<EventNode Id='2' FeatureFile='f1.xml' Fid="1.1"
FeatureId='FeatureSet[1]/Feature[1]' EventIn='CONT' EventOut='CONT'/>

XSL:

I use the document functiont to retrieve the external document (f1.xml)
as a nodeset, and I can then use constructions such as: 

<xsl:template match="EventNode">
<li>
Hello World : <xsl:value-of select="@Id"/>
<xsl:value-of select="@EventIn"/>
<xsl:value-of select="@EventOut"/>
<xsl:variable name="doc" select="document(@FeatureFile)"/>
<xsl:apply-templates select="$doc//FeatureSet[1]/Feature[1]"/>
</li>
</xsl:template>

(the rest of the stylesheet of course has appropriate templates for the
FeatureSet & Feature tags)
or even: 

<xsl:apply-templates
select="$doc/FeatureSet[substring-before($Fid,'.')]/Feature[substring-after($Fid,'.')]"/>


However, I would like to be able to use @FeatureId directly: 

<xsl:apply-templates select="document(@FeatureFile)//{@FeatureId}"/>

Or even by catching the xpointer in a variable first and then using a
concat: 

<xsl:variable name="doc" select="document(@FeatureFile)"/>
<xsl:variable name="pointer" select="@FeatureId"/>

<xsl:variable name="pointertwo"
select="concat('$doc','//',@FeatureId)"/>
or 
<xsl:variable name="pointertwo" select="concat('$doc','//',$pointer)"/>

<xsl:apply-templates select="$pointertwo"/>

=====
Any and all help will be greatly appreciated,
Gert Bultman
Delft Technical University
Computer Graphics Dept.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.