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 5th, 2008, 12:36 PM
Registered User
 
Join Date: Nov 2008
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?

 
Old November 5th, 2008, 12:46 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 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
 
Old November 6th, 2008, 05:09 AM
Registered User
 
Join Date: Nov 2008
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.

 
Old November 6th, 2008, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2008
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





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





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