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 May 9th, 2007, 02:08 AM
Registered User
 
Join Date: May 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help to check the current node...

Hi,
I am working on XSLT to convert one XML file to the another XML file.From one file I am getting the data which needs to be displayed in other XML file.Now the problem is in the dataXML I have some elements like below:
<alerts>
     <companyAlerts>
        <publication>
        </publication>
        <recommendation>
        </recommendation>
     </companyAlerts>
</alerts>

Now the problem is in the <companyAlerts> element either the <publication> or <recommendation> would be there.it means at a time only one tag would be there and depending on it I have to display the data in different format.So I want to know how I can check that which tag is there <publication> or <recommendation> ?Please help me with this.

DPD
 
Old May 9th, 2007, 02:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can write one template rule for each case:

<xsl:template match="companyAlerts[publication]">
 ...
</xsl:template>

<xsl:template match="companyAlerts[recommendation]">
 ...
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare current value with previous parent node ratjetoes XSLT 2 July 17th, 2008 06:15 AM
check name of the current node element in xml arunagottimukkala XSLT 19 October 19th, 2007 04:44 AM
Position of a node outside current context QuickSilver002 XSLT 2 April 19th, 2007 02:07 PM
XSLT Going up a level from current node. lafilip XSLT 4 February 23rd, 2007 03:06 PM
"for-the-current-node" instead of "for-each" ? webhead XSLT 2 August 25th, 2006 02:55 PM





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