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

Re: Inconsistency between XPath 1.0 and XSLT 1.0 trea

Subject: Re: Inconsistency between XPath 1.0 and XSLT 1.0 treatment of processing instruction initial whitespace
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 20 Jul 2004 14:39:50 +0100
xpath processing instruction pi
[I killed xsl-list as you're not supposed to cc this list and another (and
  I got ticked off by our esteemed list owner last time I tried:-) ]

> In other words, the xsl:processing-instruction element appears able to 
> create processing instructions that are not legal in the XPath 1.0 data 
> model.

I don't think that's necessarily a problem for 1.0, it just means that

  <xsl:processing-instruction name="testcase">
This is the content of a PI
   </xsl:processing-instruction>


generates

<?testcase 
This is the content of a PI
   ?>

which if re-parsed produces some input equvalent to

<?testcase This is the content of a PI
   ?>

At no point is an inconsistent set of data produced, as XSLT 1
(unextended) can't query into the result tree fragment generated by the
xsl:processing-instruction.

However for xsl2 2...


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="/">
<xsl:variable name="x">
   <xsl:processing-instruction name="testcase">
    This is the content of a PI
   </xsl:processing-instruction>
</xsl:variable>

[[<xsl:value-of select="$x//processing-instruction()"/>]]
</xsl:template>


</xsl:stylesheet>



$ saxon8 pi.xsl pi.xsl
<?xml version="1.0" encoding="UTF-8"?>

[[
    This is the content of a PI
   ]]


so it's generated a PI with leading white space, which again can't come
from parsing an XML file, but it doesn't seem to break any of the
constraints in:

http://www.w3.org/TR/xpath-datamodel/#ProcessingInstructionNode

(as there are no constraints:-)

so even here, this seems to be OK, I think, although it's not common in
xslt to be able to generate a result tree that can't be generated by
parsing an xml file.

The alternative I suppose would be for xsl:proccing-instruction to strip
any leading white space from its supplied content.


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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.