[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Add to XSL so it disregards certain lines on incoming xml

I have an XSL with a for-each select that ignores the text FRGT.  I need to add that it should also ignore FRGH.  How do I add it?

<xsl:for-each select="SorSalesOrderInvoiceDocuments/SalesOrderInvoiceDocument/Merchandise[MStockCode/text() != 'FRGT']">

Thank you
0
MrWeen
Asked:
MrWeen
  • 3
1 Solution
 
Geert BormansCommented:
<xsl:for-each select="SorSalesOrderInvoiceDocuments/SalesOrderInvoiceDocument/Merchandise[not(MStockCode= 'FRGT') and not(MStockCode = 'FRGH')]">
0
 
Geert BormansCommented:
two notes

- it is better to use not(... = ...) instead of ... !=... since equality in a predicate is a set compare
- you should not compare against the text() node because the text you are comparing against can be split in multiple text nodes

I usually compare against the normalized-space actually

<xsl:for-each select="SorSalesOrderInvoiceDocuments/SalesOrderInvoiceDocument/Merchandise[not(normalize-space(MStockCode)= 'FRGT') and not(normalize-space(MStockCode) = 'FRGH')]">
0
 
MrWeenAuthor Commented:
Thank you.  This worked perfectly.  Thank you for the additional tips as well.
0
 
Geert BormansCommented:
welcome
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now