[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: Comparing content
Subject: RE: Comparing content From: Ben Robb <Ben@xxxxxxxxxx> Date: Mon, 13 Sep 1999 18:04:41 +0100 |
Seems to work for me. This is the complete code: ************************************************ XML Page ************************************************ <?xml version="1.0" ?> <DOCUMENT> <TAG1>something</TAG1> <TAG2>something</TAG2> <TAG3>something else</TAG3> <TAG4>whatever<TAG5>something else</TAG5>next</TAG4> </DOCUMENT> ************************************************* XSL page ************************************************* <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <xsl:if test="//DOCUMENT[TAG1 = TAG2]"> <xsl:value-of select="//DOCUMENT/TAG1"/> </xsl:if> <BR/> <xsl:if test="//DOCUMENT[TAG3 = TAG4/TAG5]"> <xsl:value-of select="//TAG5"/> </xsl:if> </xsl:template> </xsl:stylesheet> *********************************************** Output *********************************************** something<BR/>something else *********************************************** You could also use the "for-each" syntax if there were more than one: <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <xsl:for-each select="//DOCUMENT[TAG1 = TAG2]"> <xsl:value-of select="TAG1"/> </xsl:for-each> <BR/> <xsl:for-each select="//DOCUMENT[TAG3 = TAG4/TAG5]"> <xsl:value-of select="TAG3"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> (which gives the same output in this case) What parser are you using? Rgs, Ben Robb cScape > -----Original Message----- > From: Peter-Paul Koch [mailto:ppk@xxxxxxxxxx] > Sent: 13 September 1999 17:13 > To: xsl-list@xxxxxxxxxxxxxxxx > Subject: RE: Comparing content > > > >Try something like: > ><xsl:if test="DOCUMENT[TAG1 = TAG2]"> > > <!-- do something --> > ></xsl:if> > > > >or > > > ><xsl:if test="DOCUMENT[TAG1 = TAG3/TAG4]"> > > <!-- do something --> > ></xsl:if> > > This is exactly what I've tried for days now, it just won't > work. As soon > as you put a string behind the '=' everything works fine, but I want a > dynamic comparision. > > Cuurently I try in the <xsl:template select="role">: > > <xsl:apply-templates select="/JDF/project/role[@id = ./supervisor]" /> > > where the basic XML is > > <role id="pm"> > <blah...> > </role> > > <task> > <supervisor>pm</supervisor> > <blah...> > </task> > > Nothing happens... > > Provisional version: http://www.netlinq.nl/interest/xml/interest.xml > > ppk > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Date conversion/handling functions, Clark C. Evans | Thread | RE: Comparing content, Peter-Paul Koch |
Re: Formatting an element at the en, Silveste® Poza®nik | Date | Re: Comparing content, Chris Holmes |
Month |