XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Posttop
KJ KJSubject: Apply-templates and processing nodes
Author: KJ KJ
Date: 27 Aug 2008 02:08 AM
Originally Posted: 27 Aug 2008 02:06 AM
Hello,
I have a xml with below structure
<r1>
<c1 value="1">
<gc1 value="1"> <!-- need to check this node value and process other siblings-->
<gc2 value="2">
<gc3 value="3">
<gc4 value="4">
<gc5 value="5">
</c1>
<!-- all below nodes are just need to be copied into target xml doc -->
<c2 value="2">
<gc1 value="1">
<gc2 value="2">
<gc3 value="3">
<gc4 value="4">
<gc5 value="5">
</c2>
.
.
.
.
.<!-- Some more nodes are here-->
.
.
.
</r1>

I have a xslt to process node /r1/c1/gc1 as below, which works fine except:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" .......>
.
.
.
.
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match ="r1">
<root>
<xsl:apply-templates select="node()" />
<xsl:apply-templates select ="c1/gc1" />
</root>
</xsl:template>
<xsl:template match="c1/gc1>
<!-- check the value attribute (1) for this node and process it -->
</xsl:template>
.
.
.
.</xsl:stylesheet>

This xslt calls [template match="c1/gc1"] twice bcs of <xsl:template match="node()"> in the top.
Ideally, i need to process the nodes in r1/c1 and copy up all other elements as it is.
could any one post, how to rewrite this xslt?

ps. I understand that by removing
<xsl:apply-templates select ="c1/gc1" /> line will work perfectly, though is there a way to give a name for this node and exclude it from processing again?

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.