Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2008, 04:39 AM
Registered User
 
Join Date: Sep 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to get the value-of the node dynamically?

Hi all,

I have an XML that is generated dynamically (at runtime), so the number of sub nodes (subnode here is column) is not defined earlier.
In the following example, the xPath rowSet/row/column is defined at run time.
My requirement is to get the values of the node column whose names vary from wh.actual0 to wh.actual3 (in our case, we have 4 column nodes.).
I tried appending the numbers to the name of the column, but that doesn't work out.

How to get the values of those columns?

Waiting for the reply...
<rowSet>
<row num="0">
<column name="wh.seriesName" indexed="false">Prius</column>
<column name="wh.actualTotal" indexed="false">13230</column>
<column name="wh.actual0" indexed="true">300</column>
<column name="wh.actual1" indexed="true">300</column>
<column name="wh.actual2" indexed="true">3200</column>
<column name="wh.actual3" indexed="true">300</column>
</row>
<row num="1">
<column name="wh.seriesName" indexed="false">Camry</column>
<column name="wh.actualTotal" indexed="false">13230</column>
<column name="wh.actual0" indexed="true">300</column>
<column name="wh.actual1" indexed="true">300</column>
<column name="wh.actual2" indexed="true">300</column>
<column name="wh.actual3" indexed="true">300</column>
</row>
</rowSet>

Last edited by sayanand; December 17th, 2008 at 04:43 AM..
 
Old December 17th, 2008, 05:17 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 2.0, use

rowSet/row/column[matches(@name, 'wh.actual[0-9]')]

If you tried something that didn't work, then it's a good idea to say exactly what you tried (and exactly how it failed), so that we can tell you where you went wrong.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 18th, 2008, 05:27 AM
Registered User
 
Join Date: Sep 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for the reply.

I am working with XSLT 1.0 and so, can you tell me how to do it in 1.0?

Expecting a reply
 
Old December 18th, 2008, 05:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You could use

rowSet/row/column[translate(@name, '0123456789', '9999999999') = 'wh.actual9']
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically cha nging root node!!!!!!! rakesh XSLT 4 July 29th, 2008 09:31 AM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
how to read node dynamically gantait XSLT 4 February 27th, 2007 11:01 AM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.