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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.