|
Subject: RE: [xsl] using xsl:if to test the value of a node From: Jarno.Elovirta@xxxxxxxxx Date: Thu, 5 Dec 2002 09:05:25 +0200 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] using xsl:if to test the , Michael Kay | Thread | [xsl] How to give out XML-Tags?, Sorin Marti |
| [xsl] using xsl:if to test the valu, Kevin Friend | Date | [xsl] How to give out XML-Tags?, Sorin Marti |
| Month |