Subject: Re: [xsl] xpath question From: xslt.new <xslt.new@xxxxxxxxx> Date: Wed, 24 Jan 2007 09:53:30 -0600 |
However are you sure you need to process all scene elements out of sequence like this?
The reason for me to figure out if <scene> is located under <list1> or <list2> is because I would like to filter out data based on certain conditions on the <scene> tag.
So, if I have parameters set1 and set 2 on the style sheet set to Yahoo and google, I want all elements which have Yahoo and google. If at the <list1> level itself, this condition fails, then I do not want to even check if this condition satisfies under <list2>. this is where I was having difficulty with the xpath, because when I said .//scene, it matches all <scene> elements under <list1> which includes <list2> also. I do not want that to happen. How do I achieve this? I am testing for these conditions under templates <list1> and <list2>.
<list1> <text> <para> <scene> <set1></set1> <set2></set2> </scene> </para> </text> <list2> <text> <para> <scene> <set1></set1> <set2></set2>
</scene> </para> </text>
<list2> </list1>
<list1> <text> <para> <scene> <set1></set1> <set2></set2> </scene> </para> </text> <list2> <text> <para> <scene> <set1></set1> <set2></set2>
</scene> </para> </text>
<list2> </list1>
I can't remember if you are using xslt2 or xslt1, a direct encoding of
> if I want to locate only the <scene> > element under ALL<list1> elements in the whole XML input inside the > <list1> template, and NOT the <scene> element under <list2>,
in xpath2 would be
.//scene except .//list2//scene
in xpath1 you could use
.//scene[not(ancestor::list2)]
(which doesn't mean quite the same thing in general but will select the same things so long as list1 is never a descendent of list2.
However are you sure you need to process all scene elements out of sequence like this?
more commonly in xslt you woul djust have a tempolate for scene elements
<xsl:tempate match="scene">...
and a higher priority template for scenes under list2
<xsl:tempate match="list2//scene">...
and so don't need to explictly select those scenes which are under list1 but not under list2, they automatically are matced by the first template.
David
Please read the posting guidelines for this list which advise you not to use subject lines such as "xpath question" which could apply to most of teh postings on this list.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xpath question, David Carlisle | Thread | Re: [xsl] xpath question, David Carlisle |
Re: [xsl] XSLT 2.0 has arrived, Nic James Ferrier | Date | Re: [xsl] xpath question, David Carlisle |
Month |