filter nodes by looking in "multiple grandchilds"
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Thu Sep 06, 2007 5:54 pm
filter nodes by looking in "multiple grandchilds"
Post by thomasstock »
Hello all,
I realise my title isn't clear, but neither is this problem for me
First of all, here's my XML (I simplified it a bit):
So I have multiple product nodes which each have 0, 1 or more "productLogisticInfo" child nodes.
What I'm trying to do, is to filter out a nodeset of these product nodes by looking if one of their child nodes has a "data" node containing a certain category.
So if I look for "Retail" it should return the "product A" and "product B" nodes. Looking for "Food Service" should return the product B node.
I have partially solved this problem, but my current solution only checks the first "productLogisticInfo" node of each product, and ignores the other ones.
This is what I currently use to filter a nodeset: (again, I simplified my real code)
$matchedNodesPreLogisticFilter contains a node set of products.
This piece of code would only return the second product since the first product's "Retail" category is in the second child productLogisticInfo node.
How can I make it return both product nodes?
Thank you in advance.
I realise my title isn't clear, but neither is this problem for me

First of all, here's my XML (I simplified it a bit):
Code: Select all
<products>
<product id="1185" nodeName="product A">
<productLogisticInfo id="1191">
<data alias="category">Industry</data>
</productLogisticInfo>
<productLogisticInfo id="1192">
<data alias="category">Retail</data>
</productLogisticInfo>
</product>
<product id="2185" nodeName="product B">
<data alias="productNumber">123</data>
<productLogisticInfo id="2191">
<data alias="category">Retail</data>
</productLogisticInfo>
<productLogisticInfo id="2192">
<data alias="category">Industry</data>
</productLogisticInfo>
<productLogisticInfo id="2192">
<data alias="category">Food Service</data>
</productLogisticInfo>
</product>
</products>
What I'm trying to do, is to filter out a nodeset of these product nodes by looking if one of their child nodes has a "data" node containing a certain category.
So if I look for "Retail" it should return the "product A" and "product B" nodes. Looking for "Food Service" should return the product B node.
I have partially solved this problem, but my current solution only checks the first "productLogisticInfo" node of each product, and ignores the other ones.

This is what I currently use to filter a nodeset: (again, I simplified my real code)
$matchedNodesPreLogisticFilter contains a node set of products.
Code: Select all
<xsl:variable name="matchedNodes" select="$matchedNodesPreLogisticFilter[child::node()/data[@alias = 'category'] = 'Retail'"></xsl:variable>
How can I make it return both product nodes?
Thank you in advance.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service