Hi Mike:
I try to use some example to explain my question.I
really need fix it.
Example:
My xml file is:
<List>
<List_ID>10</List_ID>
<Title>A</Title>
<ParentID>1</parentID>
</List>
<List>
<List_ID>11</List_ID>
<Title>B</Title>
<ParentID>1</parentID>
</List>
<List>
<List_ID>12</List_ID>
<Title>C</Title>
<ParentID>10</parentID>
</List>
<List>
<List_ID>13</List_ID>
<Title>D</Title>
<ParentID>10</parentID>
</List>
<List>
<List_ID>14</List_ID>
<Title>E</Title>
<ParentID>15</parentID>
</List>
what I need do :
1. Find all <list> node which parentID=1 (Example
List_ID ia 10 and 11)
I can use pattern as : select="List[parentID=1]"
2.and find all the
<list> node which parentID not equal 1 but also no
List_ID on the xml equal to the current parentID
(Example: List_ID is 14. so Its parentID is 15. when
we search all List node where List_ID =15 .no macth
so List_ID=14 is node which I need count)
Let's assume that when you say "the current parentID", your context node is
actually a List element, and you mean "the parentID child of the context
List element". I also assume that there is a single wrapper element around
the List elements.
Your condition then translates into
/*/List[ParentId = 1 or not(/*/List[ListId = current()/ParentId])]
(this would be a lot more efficient with keys).
In general, of course, this expression will return 0, 1 or many nodes. In
this example it returns exactly one node.
Now you say you need some kind of count. I'm not sure what you mean by this.
What would the count be in this example?
For List_ID is 12 and 13, their parentID is 10. when I
search List node which ID is equal current node
parentID (now it is 10) and it exist so List_ID is 12
and 13 is not what I want.
If 12 and 13 isn't what you want, then what do you want?
so in the xml file ,three node satisfy my filter
condition:They are
<List>
<List_ID>10</List_ID>
<Title>A</Title>
<ParentID>1</parentID>
</List>
<List>
<List_ID>11</List_ID>
<Title>B</Title>
<ParentID>1</parentID>
</List>
<List>
<List_ID>14</List_ID>
<Title>E</Title>
<ParentID>15</parentID>
</List>
then I need do different things based on the node
position in the satisfiled node( not all the node
list)
It is my problem. no matter what I use, I can't find
the position inside node which I filter from original
source since position() will tell you the position on
the source.
If you use this expression:
/*/List[ParentId = 1 or not(/*/List[ListId = current()/ParentId])]
in an xsl:for-each or xsl:apply-templates, then it will select three nodes,
and the positions of those nodes will be 1, 2, and 3.
I wish you can understand my question now.
I wish it too, but I'm not at all sure I have understood correctly.
Michael Kay
http://www.saxonica.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--