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 8th, 2009, 06:05 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default How to Match Nested List Tag

Hi All,

We have modified the XSL to match the nested tags:

We can able to match the first-level of tags but when it comes to nested, the html output will not displayed the text.

Input:
Code:
<list id="l005" type="number">
	<listItem><para id="p005">The combat equipment consists of:</para>
		<list id="l00501" type="number">
			<listItem><para id="p005001">launch tube, which comprises 2 sections:</para>
				<list id="l005002" type="number">
					<listItem><para id="l0050011">nose section, with.. of the sensor</para></listItem>
					<listItem><para id="l0050012">control section, with.. to fly the missile</para></listItem>
				</list>
			</listItem>
		</list>
	</listItem>
</list>
XSL:
Code:
<xsl:template match='list[@type="number"]'>
     <OL STYLE="color: red">
       <xsl:for-each select="listItem/para">
          <LI Style="list-style-type: arabic; font-family: Times New Roman; font-size:9pt;  font-weight:normal;">
     <xsl:apply-templates/>
          </LI>
	  </xsl:for-each>
</OL> 
</xsl:template>
Using the above xsl, we can able to find the first level of the listItem/Para elements but we have to find the inner-level (nested) of the same xpath. Please provide some solutions to help..

Note: Our processing declaration is as follows:
Code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

Thanks
 
Old December 8th, 2009, 06:18 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>The WD-xsl dialect of XSLT (loosely based on a 1998 working draft of the language) has been obsolete for over 10 years, and it's impossible now to find documentation on it. I would suggest that the first thing you do is switch to using standard XSLT.

xmlns:xsl="http://www.w3.org/TR/WD-xsl"
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 8th, 2009, 06:22 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default

Thanks for your response. These XSL was created long back, but our client was instructed to modified the XSL based on the nested tag from the existing one(Not advised to created new one). It would be highly appreciated if you assist me on this...

Thanks,
 
Old December 8th, 2009, 06:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry if I wasn't clear. I can't help you with a stylesheet written in WD-xsl because I can't remember the specification of the language and can't find an online resource for it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 8th, 2009, 06:42 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default

Okay but please advise how to find nested tags using the below specification
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

We will use your snippets as guide and make changes in the old XSL(let's try ourselves).

Hope this is clear..


Thanks
 
Old December 8th, 2009, 06:44 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

When you are running the xsl:apply-templates above your current context is within the <para> element. There are no children of this element, therefore nothing is output.

All subsequent <list> elements appear to be siblings of the <para> element, but it isn't clear from your sample XML the exact rules governing when a <para> and <list> element appear.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old December 8th, 2009, 06:52 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default

Hi,

In our xsl:
Code:
<xsl:for-each select="listItem/para">
will match para element. [Not a Nested Version].

We have to use the same XSL with Nested Version.

Please provide some guidance how to match the element which is of nested tags.

Thanks
 
Old December 8th, 2009, 06:53 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try the below:
Code:
<xsl:template match='list[@type="number"]'>
     <OL STYLE="color: red">
       <xsl:for-each select="//listItem/para">
          <LI Style="list-style-type: arabic; font-family: Times New Roman; font-size:9pt;  font-weight:normal;">
     <xsl:apply-templates/>
          </LI>
	  </xsl:for-each>
</OL>
</xsl:template>
If this is not what you need, then please post the needed output xml.
__________________
Rummy

Last edited by mrame; December 8th, 2009 at 07:02 AM..
 
Old December 8th, 2009, 07:26 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default

Here is the input XML file:

Code:
<product>
<title>Missile systems</title>
<para id="p001">The Bulgarian Company, Vazovski..</para>
<list id="l005" type="number">
<listItem><para id="p005">The combat equipment consists of:</para>
<list id="l00501" type="number">
<listItem><para id="p005001">launch tube, which comprises 2 sections:</para>
<list id="l005002" type="number">
<listItem><para id="l0050011">nose section, with.. of the sensor</para></listItem>
<listItem><para id="l0050012">control section, with.. to fly the missile</para></listItem>
</list>
</listItem>
</list>
</listItem>
</list>

<title>Stinger</title>
<para id="p0002">Engineers at Schweiz Unternehmung have developed</para>
<list id="l005" type="number">
<listItem><para id="p005">The combat equipment consists of:</para>
<list id="l00501" type="number">
<listItem><para id="p005001">launch tube, which comprises 2 sections:</para>
<list id="l005002" type="number">
<listItem><para id="l0050011">nose section, with.. of the sensor</para></listItem>
<listItem><para id="l0050012">control section, with.. to fly the missile</para></listItem>
</list>
</listItem>
</list>
</listItem>
</list>
</product>
From the provided xsl we can able to view the listitem/para as consolidated. But we need listitem/para as per their positions here after title element..

Note: Please use h2 for title element
rest of the html mapping are same...

Thanks
 
Old December 8th, 2009, 07:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You might find that this simple solution works:

Code:
<xsl:template match="list[@type='number']">
  <OL STYLE="color: red">
    <xsl:apply-templates/>
  </OL>
<xsl:template>

<xsl:template match="listItem">
  <LI Style="list-style-type: arabic; font-family: Times New Roman; font-size:9pt;  font-weight:normal;">
    <xsl:apply-templates/>
  </LI>
</xsl:template>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?

Last edited by samjudson; December 8th, 2009 at 07:59 AM..
The Following User Says Thank You to samjudson For This Useful Post:
rangeshram (December 8th, 2009)





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
How to make a nested list tag that is valid? chobo2 CSS Cascading Style Sheets 1 April 21st, 2009 04:07 AM
extract nested list JohnBampton XSLT 3 February 26th, 2009 06:14 AM
Nested Bullet List tims XSLT 1 May 8th, 2008 06:37 AM
To get a list of specific tag from xml using v JelfMaria VB How-To 0 January 11th, 2005 07:21 AM





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