Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 5th, 2008, 12:36 PM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Processing specific Nodes

Hi, I have a problem processing specific nodes

XML example input:


Code:
<p>The quick brown</p>
<p PPT="Yes">Jumps over the 
  [list]
    <li><p><b>Hedge</b></p></li>
    <li><p><i>River</i></p></li>
  </ul>
</P>
<p>Running</p>
in the xslt I want to process the <p PPT="Yes"> and all child entities including <p> nodes but ignore all <p> outside of it that do not have this attribute set.

so far I have had good success with everything except <p> given that in the xslt I have <xsl:template match ="p"/>

Any ideas?

Reply With Quote
  #2 (permalink)  
Old November 5th, 2008, 12:46 PM
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

Well if you want to process all p elements with attribute PPT being "Yes" then just do that e.g.
Code:
<xsl:template match="/">
<xsl:apply-templates select="//p[@PPT = 'Yes']"/>
</xsl:template>
then make sure you have a template for the p element that outputs whatever you need e.g.
Code:
<xsl:template match="p[@PPT = 'Yes']">
  <div>
    <xsl:apply-templates/>
  </div>
</xsl:template>
--
  Martin Honnen
  Microsoft MVP - XML
Reply With Quote
  #3 (permalink)  
Old November 6th, 2008, 05:09 AM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks for the input but I'm still left with the problem that any <p> objects nested in <p PPT="Yes"> doesnt get processed.

Reply With Quote
  #4 (permalink)  
Old November 6th, 2008, 05:38 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Just now I checked the posted templates with the input xml you have posted. Its working fine for your requirement. the output obtained is:
<div>Jumps over the

            Hedge
            River
        </div>

Just check whether you are doing any mistake.

------
Rummy
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To Select a specific nodes from XML vkommera XSLT 4 June 27th, 2008 03:39 PM
Search specific data from specific columns yogeshyl SQL Language 1 January 16th, 2008 11:12 AM
Copy specific data in specific cells of sheet2 yogeshyl Excel VBA 1 May 14th, 2007 07:40 AM
query processing maheshshinde ASP.NET 2.0 Basics 0 March 21st, 2007 04:14 AM
Help accessing specific nodes jshl_wiz Javascript 2 June 29th, 2005 09:45 PM



All times are GMT -4. The time now is 12:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.