xsl-list
[Top] [All Lists]

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

2011-10-27 15:04:10
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/ >
“Be wary of great leaders.  Hope that there are many, many small
 leaders.” — Pete Seeger

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

<Prev in Thread] Current Thread [Next in Thread>