Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] invalid xpath?

From: Abel Braaksma <abel.online@--------->
To:
Date: 7/2/2008 12:54:00 PM
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 --


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent