Re: [xsl] Test processing instruction as first preceding sibling

Subject: Re: [xsl] Test processing instruction as first preceding sibling
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 09 Dec 2008 17:07:23 +0100
Alexandre Moraes wrote:
Hi guys,

        I have a doubt about testing preceding-sibling processing-instruction.
        I have this xml:

       <root>
           <child1>
                   child 1
           </child1>
           <?proc?>
           <child2>
                  child 2
          </child2>
     </root>

           And I need to know if child2 has the first
preceding-sibling as a processing-instruction. In this case it should
return true.

If whitespace text nodes matter then in your sample /root/child2/preceding-sibling::node()[1] is a text node and only /root/child2/preceding-sibling::node()[2] is a processing instruction node.


I tryed something like this

preceding-sibling::*[1]/name()|preceding-sibling()[1]/name = 'proc'

<xsl:if test="preceding-sibling::node()[1][self::processing-instruction('proc')]">


should do if you strip whitespace.

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread