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

RE: using xsl:if to test the value of a node

Subject: RE: using xsl:if to test the value of a node
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 5 Dec 2002 09:05:25 +0200
xsl if value of
Hi,

> I need to only transform ARTICLE nodes where the CODE node 
> value starts with
> a "J" (or a "B").
> 
> My data looks like...
> 
> <ARTICLE_LIST>
> 	<ARTICLE Test="OK">
> 		<CODE>J107_SYD-LAX-JFK.102</CODE>
> 		<PACKAGE>PK x 15</PACKAGE>
> 		<LOADPORT>SYD QFCL</LOADPORT>
> 		<ORDERED>6300</ORDERED>
> 		<DELIVERED>0</DELIVERED>
> 		<USED>0</USED>
> 		<ONHAND>0</ONHAND>
> 		<VIEWFILE>TRUE</VIEWFILE>
> 	</ARTICLE>
> 
> I am trying the following...
> 
> <xsl:template match="/">
> 	<xsl:copy>
> 	<xsl:apply-templates/>
> 	</xsl:copy>
> </xsl:template>
> <xsl:template match="ARTICLE_LIST">
> 	<xsl:copy>
> 	<xsl:apply-templates>

change this to 

  <xsl:apply-templates select="ARTICLE[starts-with(CODE, 'J') or starts-with(CODE, 'B')]" />

> 		<xsl:sort select="CODE"/>
> 		<xsl:sort select="LOADPORT"/>
> 	</xsl:apply-templates>
> 	</xsl:copy>
> </xsl:template>
> <xsl:template match="ARTICLE">
> 	<xsl:if test="child::CODE[. $lt$ 'K' and . $gte$ 'J']">
> 	<xsl:copy>
> 		<xsl:apply-templates/>
> 	</xsl:copy>
> 	</xsl:if>
> </xsl:template>

and this template to 

  <xsl:template match="ARTICLE">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

That is, instead of selecting all ARTICLEs and filtering out all the unwanted ones, select only the wanted ARTICLEs in the first place.

--

Jarno - Front Line Assembly: Body Count


 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.