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

Re: invalid xpath?

Subject: Re: invalid xpath?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 02 Jul 2008 14:53:42 +0200
Re:  invalid xpath?
Trevor Nicholls wrote:
Thank you Abel

[...snip...]

   <xsl:when test="not(preceding-sibling::*)[starts-with($Arg,'&#x0a;')]">
    <xsl:call-template name="WS">

[...snip...]

OK, the foregoing is invalid 1.0. So I tried modifying it to this:


 <xsl:when test="not(preceding-sibling::*) and starts-with($Arg,'&#x0a;')">
  <xsl:call-template name="WS">

Now there are no reported errors, but the test appears not to be working (at
least, there is an extra leading space in the output document wherever this
template has been called, compared with what Saxon was producing with the
original test).

In all honesty, I haven't delved into your stylesheet logic. What you are testing above is whether the current node has a preceding sibling element and whether $Arg starts with a newline character.


You don't show how the original template is called. You select the current node into $Arg (which could contain any number of children) and then you use string functions on that node, which essentially normalizes that node into a string, giving you no way whatsoever to extract any elements from it (they will all be stringized).

Is that what you want? Is that expected behavior?

If you want to remove the newlines you could make it easier on yourself by using:

translate($Arg, '&#xA;', '')


You also seem to have special cases. Why not use the template techniques for those cases? Let XSLT decide for you:


<xsl:template match="text()[following-sibling::nl]">
   ....

<xsl:template match="text()">
  ....

Then your KeepWS and WS named templates will become easier to program.

HTH,
Cheers,
-- Abel --

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-2007 All Rights Reserved.