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

Re: Passing parameter into tag name

Subject: Re: Passing parameter into tag name
From: "Steve Wisniewski stevewiz76@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Apr 2017 13:18:04 -0000
Re:  Passing parameter into tag name
Thank you Martin!

      From: "Martin Honnen martin.honnen@xxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
 Sent: Wednesday, April 12, 2017 9:11 AM
 Subject: Re:  Passing parameter into tag name

On 12.04.2017 15:06, Steve Wisniewski stevewiz76@xxxxxxxxx wrote:

> <foo>
> <Level>
> <Level_No>1</Level_No>
> </Level>
> <Level>
> <Level_No>2</Level_No>
> </Level>
> <Level>
> <Level_No>3</Level_No>
> </Level>
> <Cost ID='1'>
> <Level_1_Amt>100</Level_1_Amt>
> <Level_2_Amt>200</Level_2_Amt>
> <Level_3_Amt>300</Level_3_Amt>
> </Cost>
> <Cost ID='2'>
> <Level_1_Amt>50</Level_1_Amt>
> <Level_2_Amt>100</Level_2_Amt>
> <Level_3_Amt>150</Level_3_Amt>
> </Cost>
> <Cost ID='3'>
> <Level_1_Amt>175</Level_1_Amt>
> </Cost>
> <Cost ID='4'>
> <Level_3_Amt>400</Level_3_Amt>
> </Cost>
> </foo>
>
> I am trying to sum up the amounts in the following code, but am getting
> a syntactical error about how I am trying to pass the parameter value
> into the tag name:
>
> <xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:template name="buildLevel">
> <xsl:param name="levelNum"/>
> <Level_Amt>
> <xsl:value-of select="sum(/Story/Level_{$levelNum}_Amt)"/>

You need to check the name with e.g.
B  B  sum(/Story/*[local-name() = concat('Level_', $levelNum, '_Amt')])

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.