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

Re: XSLT 3.0 processor accepting non well-formed XML

Subject: Re: XSLT 3.0 processor accepting non well-formed XML inputs
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Mar 2019 17:16:42 -0000
Re:  XSLT 3.0 processor accepting non well-formed XML
Determining exactly when early exit is and isn't possible is quite subtle. In
this case early exit would be possible in theory, if Saxon were a bit
smarter:

* you have to know that the input XDM tree is coming straight from an XML
parser, therefore it is supposed to be a well-formed instance with only one
top-level element

* you have to know that comments and processing instructions generate no
output, because there are no template rules that match them, and the default
template rules for comments and PIs do nothing. If there were a second
template rule

<xsl:template match="comment()">*****</xsl:template>

then Saxon would clearly have to continue parsing to the end just in case of
possible comments.

Generally, if early termination is important to you, then it's best to start
with a template rule saying match="/". You would get early termination for
this stylesheet (I think) if you wrote

> <xsl:template match="/">
>        <result>
>           <xsl:iterate select="/foo/*">
>             <xsl:choose>
>                <xsl:when test=". != '0'">
>                   <mesg>
>                      <xsl:value-of select="'hello'"/>
>                   </mesg>
>                </xsl:when>
>                <xsl:otherwise>
>                   <xsl:break/>
>                </xsl:otherwise>
>             </xsl:choose>
>           </xsl:iterate>
>        </result>
>     </xsl:template>

Michael Kay
Saxonica

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.