xsl-list
[Top] [All Lists]

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

2002-12-05 00:05:25
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



<Prev in Thread] Current Thread [Next in Thread>