[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using xsl to test value of node

Subject: RE: Using xsl to test value of node
From: "Chris Bayes" <chris@xxxxxxxxxxx>
Date: Thu, 13 Dec 2001 15:55:54 -0000
xsl test value
<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="normalize-space()='44639'">  
    <xsl:apply-templates select="../LOCATION_ID"/> 
   </xsl:if>
</xsl:template>

<xsl:template match="LOCATION_ID">
  <html>
    <body>
      <h1>
        <xsl:value-of select="."/>
      </h1>	 
    </body>
 </html>
 </xsl:template>    
</xsl:stylesheet> 

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Ahmad J Reeves
> Sent: 13 December 2001 15:19
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Cc: Ahmad Reeves
> Subject:  Using xsl to test value of node
> 
> 
> 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
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.