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 4th, 2007, 12:18 PM
Authorized User
 
Join Date: Dec 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default xslt for each help

I need to iterate using for each for each element under //tableData/row/strData and //tableData/row/dblData

The problem is i dont want to write 2seperate for each for this
example
<xsl:for-each select="tableData/row/strData">
and
<xsl:for-each select="tableData/row/dblData">


instead of this - to get data under tableData/row/strData or dblData can we write a single for each.
How will the tag look like.Is it something to do with regexp.


code pasted below


<tableData>
<row>
<strData>
<mapping>Bucket</mapping>
<alignment>center</alignment>
<stringValue>008.00 to 012.00</stringValue>
</strData>
<strData>
<mapping>A</mapping>
<alignment>1center</alignment>
<stringValue>BBB</stringValue>
</strData>
<dblData>
<mapping>Loan</mapping>
<alignment>right</alignment>
<values>
<value formatString="#,##0">2585.0</value>
</values>
<showZeros>true</showZeros>
</dblData>
</row>
</tableData>

 
Old December 4th, 2007, 12:34 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Perhaps:

<xsl:for-each select="tableData/row/strData | tableData/row/dblData">

or if strData and dblData are the only possible subitems of row then:

<xsl:for-each select="tableData/row/*">

/- Sam Judson : Wrox Technical Editor -/
 
Old December 4th, 2007, 12:35 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you are using XSLT 2.0 then you can use
Code:
  <xsl:for-each select="tableData/row/(strData | dblData)">
If you are using XSLT 1.0 then you can use
Code:
  <xsl:for-each select="tableData/row/strData | tableData/row/dblData">
 
Old December 4th, 2007, 12:53 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 1.0:

xsl:for-each select="a/b/c | a/b/d"

In 2.0 you can also do:

xsl:for-each select="a/b/(c|d)"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 4th, 2007, 02:35 PM
Authorized User
 
Join Date: Dec 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael Kay...Indeed I bought your book XSLT 2.0 Yesterday...It Will take me some time to reach your level :-)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating XSLT with XSLT stonis XSLT 3 April 1st, 2008 08:17 PM
General XSLT Questions in the XSLT Forum jminatel BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 0 March 31st, 2008 07:50 PM
Can XSLT read DTD/schema and Generate XSLT.. ROCXY XSLT 1 November 6th, 2006 09:39 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
xslt with an xslt outputfile alleycat XSLT 4 February 20th, 2006 09:56 AM





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