Subject: [xsl] Using xsl to test value of node From: Ahmad J Reeves <ahmad@xxxxxxxxxxxxxx> Date: Thu, 13 Dec 2001 15:19:09 +0000 |
I am trying to test the value of a node and if it contains a certain value, then to extract a value from a second node, so here is an excerpt from the xml: <LOG> <DIRECT> <COMMUNICATION_TYPE> PAGETELL </COMMUNICATION_TYPE> <Invoc_serial> 27 </Invoc_serial> <Serial> 3087908 </Serial> <USAGE> TELL </USAGE> <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE> <CHARACTER_ID> 44639 </CHARACTER_ID> <CHARACTER_STATUS> 3 </CHARACTER_STATUS> <LOCATION_ID> 45040 </LOCATION_ID> <TARGET_CHARACTER_ID> 23470 </TARGET_CHARACTER_ID> <TARGET_CHARACTER_STATUS> 6 </TARGET_CHARACTER_STATUS> <TARGET_CHARACTER_LOCATION_ID> 23222 </TARGET_CHARACTER_LOCATION_ID> <MESSAGE> Hello </MESSAGE> <TIME> 'Mon, 26 Nov 2001 15:40:29 +0000' </TIME> </DIRECT> </LOG> So for example if <CHARACTER_ID> = 44639 I need to output say in html format the value of <LOCATION_ID> Here is my first stab at the code (not working) <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="LOG"> <xsl:apply-templates select="DIRECT"/> </xsl:template> <xsl:template match="DIRECT"> <xsl:apply-templates select="CHARACTER_ID"/> </xsl:template> <xsl:template match = "CHARACTER_ID"> <xsl:if test() ="44639"/> <xsl:apply-templates select="LOCATION_ID"/> </xsl:if> </xsl:template> <xsl:template name="LOCATION_ID"> <html> <body> <h1> <xsl:value-of select="."/> </h1> </body> </html> </xsl:template> </xsl:stylesheet> I know xml-if only returns a true or false boolean value and have also tried setting variables but with no success. Thanks Ahmad ----------------------------------------------------- Ahmad J. Reeves BSc(Hons), MSc(Dist). Phd Student Information, Media, and Communication Research Group, Dept of Computer Science,Queen Mary,University of London, E1 4NS Tel +44 (0)20 7882 5257 http://www.dcs.qmw.ac.uk/imc/ ----------------------------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XPath in Java Q?, Michael Kay | Thread | Re: [xsl] Using xsl to test value o, David Carlisle |
RE: [xsl] Dumb questions from a new, Mike Ferrando | Date | Re: [xsl] Using xsl to test value o, David Carlisle |
Month |