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 November 16th, 2016, 05:26 AM
Authorized User
 
Join Date: Nov 2016
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Post Grouping List using XSLT2.0

INPUT HTML:

<p class="L-Listi" style="margin-left:36pt; text-indent:-36pt"><span>(i)</span><span style="font:7.0pt 'Times New Roman'">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&# xa0; </span>
<span>Bowen/Surat Basins (Qld);</span>
</p>

<p class="L-Listi" style="margin-left:36pt; text-indent:-36pt">
<span>(ii)</span>
<span>Gunnedah Basin (NSW);</span>
</p>

<p class="L-Listi" style="margin-left:36pt; text-indent:-36pt">
<span>(iii)</span>
<span>Sydney Basin (NSW).</span>
</p>

Need Output:
<list before="(" after=")" type="lcr">
<li>
<ptext>Bowen/Surat Basins (Qld);</ptext>
</li>
<li>
<ptext>Gunnedah Basin (NSW);</ptext>
</li>
<li>
<ptext>Sydney Basin (NSW).</ptext>
</li>
</list>
 
Old November 16th, 2016, 06:01 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Hints for a good XSLT post
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 16th, 2016, 06:25 AM
Authorized User
 
Join Date: Nov 2016
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Quote:
Originally Posted by samjudson View Post
I tried the below code but its output comes in individual block. I need all the li items within single <list> element. Please suggest..

<xsl:template match="p[@class='L-Listi']">
<list>
<xsl:attribute name="type" select="'lcr'"/>
<li>
<ptext>
<xsl:apply-templates/>
</ptext>
</li>
</list>
</xsl:template>
 
Old November 16th, 2016, 06:49 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Your template matches each 'p' in turn, so it will output everything inside that template for each 'p' element. You need to match based on the parent element of all the 'p' (which you haven't shown) to output the 'list' element, and then in the template that matches the 'p' just output each 'li' element.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 16th, 2016, 08:04 AM
Authorized User
 
Join Date: Nov 2016
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Quote:
Originally Posted by samjudson View Post
Your template matches each 'p' in turn, so it will output everything inside that template for each 'p' element. You need to match based on the parent element of all the 'p' (which you haven't shown) to output the 'list' element, and then in the template that matches the 'p' just output each 'li' element.
Thank You Very much samjudson. Can you please send any sample code related this one.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping the nested list accroding to the level priyan24 XSLT 2 November 17th, 2009 07:17 AM
xslt2.0 Parser choices amhicraig XSLT 3 December 8th, 2007 10:29 PM
jaxp and xslt2 multiple output aowss XSLT 2 October 10th, 2007 01:21 AM
Multiple Grouping in List ROCXY XSLT 0 January 7th, 2006 05:16 AM
Grouping List chemi XSLT 1 October 20th, 2005 09:36 AM





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