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
Joshua HuntSubject: Using a parameter (or similar) in a SELECT
Author: Joshua Hunt
Date: 08 Sep 2009 08:08 AM
Hi,

I have a file that is basically:

<Row>
<Header1>aa</Header1>
<Header2>ab</Header2>
<Header3>ac</Header3>
</Row>
<Row>
<Header1>aa</Header1>
<Header1>ba</Header1>
</Row>

I have a need to select every second element within a <Row> until there are none left and then move on to the next <Row>.

I am using a template to increment a value that is passed into a SELECT, but there does not seem to be a way to pass a changeable value (that represents a Node) into a SELECT. Does anyone have any ideas? Here is my cutdown stylesheet:

<xsl:template match="/">
<xsl:for-each select="//row">
<xsl:call-template name="Detail">
<xsl:with-param name="value">2</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="Body">
<xsl:value-of select="Heading1/text()"/>
<xsl:text>,</xsl:text>
</xsl:template>
<xsl:template name="Detail">
<xsl:param name="name" select="'Heading'"/>
<xsl:param name="value"/>
<xsl:param name="heading" select=" concat($name,$value)"/>

<xsl:value-of select="$heading"/> <!-- An IF statement would be better, but can't seem to pass in a Node using parameter value for this either -->
<xsl:call-template name="Body"/>
<xsl:with-param name="value" select="$value + 2"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

Posttop
Joshua HuntSubject: Using a parameter (or similar) in a SELECT
Author: Joshua Hunt
Date: 08 Sep 2009 08:47 AM
Hi all,

I managed to find the answer on the net, so for completeness I am using:

<xsl:for-each select="*[local-name()=$heading]">
<xsl:value-of select="."/>
</xsl:for-each>

Assuming anyone understood my original question above, as I don't on reading it again :).

Here is a link to the post that I used: http://forums.tizag.com/showthread.php?t=9289

 
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.