Subject: Re: [xsl] How to find out if the preceding sibling is a PI From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 2 Dec 2005 21:40:27 GMT |
] Hi all, ] ] I have a document that looks something like this: ] ] <?xm-insertion_mark_start author="Nadia Swaby" ] time="20051202T111856-0500"?> ] <design.consideration></design.consideration> ] ] I need to do a test to find out if the sibling immediately preceding the ] design.consideration element is an xm-insertion_mark_start PI. ] ] Basically, I need something like ] preceding-sibling::*[position() = 1 and ] processing-instruction('xm-insertion_mark_start')] ] but that statement doesn't return anything. ] ] Is there any way of doing this? ] Yes you just need to be more careful in your natural language description of the problem, then the xpath follows naturally. You show three nodes, a PI, a text node with value a newline character, and an element node with name design.consideration. preceding-sibling::* selects preceding _elements_ so if teh current node is the design.consideration element, it won;t select anything (so the predicate has no effect. If there was an earlier element selected by the * , the predicate would select the element if it was the first element (counting backwards) and if it had a _child_ processing instruction. So I think what you actually want to ask is if the first node (in reverse order) that is not white space text is a PI owith the name xm-insertion_. so preceding-sibling::node[not(self::text()[normalize-space()=''])] [1] [self::processing-instruction('xm-insertion_mark_start')] David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to find out if the pr, Michael Kay | Thread | Re: [xsl] How to find out if the pr, JBryant |
RE: [xsl] How to find out if the pr, Michael Kay | Date | Re: [xsl] Finding deepest node, Jon Gorman |
Month |