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
Postnext
Soeren BendtsenSubject: Have XSL determine action on one element based on attribute value of another element
Author: Soeren Bendtsen
Date: 09 Feb 2007 08:18 AM
Consider the following base structure in a source XML file:

(......)

<webmessage use="Cap">
<text>Dist1 ABC</text>
</webmessage>

<webmessage use="Description">
<text>ZYZ Dist2</text>
</webmessage>

(......)

I want to apply a simple template like the below on <text> elements:

<text_mod>
<xsl:value-of select="@attrib"/>
<xsl:apply-templates/>
</text_mod>

But ONLY when the use= attribute in webmessage is "Description".

I have tried using xsl:if, but cannot get a condition on an attribute in the webmessage element to affect what happens to the following text element. Any help is appreciated. Pls. be quite specific, as I am a newbie with XSLT.

This is then the XML that should come out of the process:

(......)

<webmessage use="Cap">
<text>Dist1 ABC</text>
</webmessage>

<webmessage use="Description">
<text_mod>ZYZ Dist2</text_mod>
</webmessage>

(......)

Thanks; Soeren

Postnext
Tony LavinioSubject: Have XSL determine action on one element based on attribute value of another element
Author: Tony Lavinio
Date: 09 Feb 2007 09:08 AM
The standard solution is to use the 'identity' stylesheet
and put in exceptions to intercept the elements you want to
change.

See the attached.


Documentsoeren.xsl

Posttop
Soeren BendtsenSubject: Have XSL determine action on one element based on attribute value of another element
Author: Soeren Bendtsen
Date: 09 Feb 2007 05:10 PM
Thank you very much, Tony. This did exactly what I needed. Saved me from much investigation and frustration. Have a super day.

 
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.