xsl-list
[Top] [All Lists]

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

2008-12-09 11:07:53
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/

--~------------------------------------------------------------------
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>
--~--