Arvid Boome
Arvid Boome

Reputation: 49

how to filter an xml file using the expressions < or < in xslt?

Hi I'm trying to display a number of things that match a certain criteria. In my xml file i have a bunch of 'suppliers'

<Suppliers>
 <ASupplier>
  <SupplierId> 12 </SupplierId>
  <SupplierName> Amazon </SupplierName>
  <Email> [email protected] </Email>
  <StartDate> 01</11</2010 </StartDate>
  <ContractLength> 6 </ContractLength>
  <AnnualTurnover> 1233.32 </AnnualTurnover>
 </ASupplier>
</Suppliers>

This is the code from my xslt file

<xsl:if test="$SearchType = 'Length'">
 <xsl:for-each select="ASupplier[$SupplierFilter >= ContractLength]">
  <tr>
   <td>
    <xsl:value-of select="../SupplierName"/>
   </td>
  </tr>
 </xsl:for-each>
</xsl:if>

the 'SearchType' is a parameter. The problem im having is that im getting back empty data instead of a table with the name inside. It returns the correct number but without any data i.e. i have 3 suppliers with contract length of 6 or less and if i type 6 and search it brings back 3 table cells but without any data. Any thoughts. p.s I have the functions start-with and contains that use similar code and work just fine.

Upvotes: 0

Views: 101

Answers (1)

David Carlisle
David Carlisle

Reputation: 5652

the input you show lost its XML tags so it is hard to see what the xslt is acting on (I'll put them back).

that said I would guess that

<xsl:value-of select="../SupplierName"/>

should be

<xsl:value-of select="SupplierName"/>

If SupplierName is a child of ASupplier

Upvotes: 1

Related Questions