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 August 18th, 2010, 09:38 AM
Authorized User
 
Join Date: Aug 2010
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default Data from specific nodes.

If I want to select only data from 2 nodes to be displayed, can I add logical operators to match?

XSLT File:(an ex)

Code:
<xsl:template match ="Order/*">
<xsl:apply-templates>
</xsl:template>

XML data:


Code:
<Order>
<DateTime>08/11/10 23:59:07.032</DateTime>
<Type>Sedan</Type>
<Color>green</Color>
</Order>



I want to get data values of type and color only . How can this be done?

Thanks.
 
Old August 18th, 2010, 09:53 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There are two ways.

Either in the parent template select only those items you do want to output, or in the child templates write templates to cover those you don't want to output.

Code:
<xsl:template match="Order">
   <xsl:apply-templates select="Type | Color"/>
</xsl:template>
or

Code:
<xsl:template match="Order">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match ="Order/*[self::Type | self::Color]" priority="2">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match ="Order/*">
<!-- For all others do nothing -->
</xsl:template>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
pushkar_joshi (August 19th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Xpath more specific or return tree fragment or nodes peterdums BOOK: XSLT Programmer's Reference, 2nd Edition 0 November 26th, 2009 09:10 AM
Copying all the nodes except the specific node arunprasadlv XSLT 14 July 22nd, 2009 09:19 AM
Processing specific Nodes Krippers XSLT 3 November 6th, 2008 05:38 AM
To Select a specific nodes from XML vkommera XSLT 4 June 27th, 2008 03:39 PM
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.