[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to find out if the preceding sibling is a PI

Subject: Re: 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
find out pi
] 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.