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

Re: XPath condition testing, can pretty-print affect?

Subject: Re: XPath condition testing, can pretty-print affect?
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Thu, 27 Oct 2011 16:03:48 -0400
Re:  XPath condition testing
On 10/27/2011 04:00 PM, Karlmarx R wrote:
> <root xmlns:....>
>     <Desc>
>         <dc:title>
>             <sc>TEXT</sc>
>         </dc:title>
>         <Many-Other-elements/>
>     </Desc>
> </root>
>
> The previously mentioned xpath rule perfectly works in the 2nd case,
> after pretty-print. But the rule does not give desired output on the
> source one-liner XML. Inspite of <dc:title/> having TEXT, it keeps
> sending the failure massage which is not what is expected. I do
> understand in certain cases pretty-print can affect certain things,
> but I have not explored much in this matter and any suggestion or
> pointer towards this would be of help.

Ah, but dc:title does *not* have TEXT.  It has newline, many spaces,
TEXT, newline, many spaces.  Your regexp has a start ^ and end $ anchor,
meaning it matches if *all* of the content is only alphanumeric.  The
leading and trailing whitespace introduced by pretty-printing does not
match.

Either use strip-space in your parser (or XSLT, if in that context), or
match on sc if appropriate, or amend your regexp to allow leading and
trailing whitespace.

~Chris
--
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
bBe wary of great leaders.  Hope that there are many, many small
 leaders.b b Pete Seeger

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.