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
lars cSubject: check if variable data, element exist
Author: lars c
Date: 05 Mar 2007 06:10 AM
Originally Posted: 05 Mar 2007 03:48 AM
Hi
I have a variable /blade/elementlink that contains data of a /blade/data tag now i would like to check if the tag /blade/data element exist in my document.
So when there exist a /blade/data tag with "some tag info" i want the XSL to print yes otherwise no.


My example code.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xslData.xsl"?>
<blade>
<elementlink>/blade/data</elementlink>
<data>some tag info</data>
</blade>

XSL:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<xsl:variable name="var1" select="/blade/elementlink" />

<xsl:template match="/">
<p>test : </p>
<xsl:value-of select="$var1"/>
<xsl:choose>
<xsl:when test="$var1">
<xsl:text>Yes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>No</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Posttop
Tony LavinioSubject: check if variable data, element exist
Author: Tony Lavinio
Date: 06 Mar 2007 08:50 AM
You can't do that.

Match expressions must be literals, not expressions.

Typically this is handled with xsl:choose blocks.

 
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.