[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: "Mukul Gandhi gandhi.mukul@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Mar 2019 05:35:41 -0000
Re:  XSLT 3.0 processor accepting non well-formed XML
Hi Martin,

On Fri, Mar 1, 2019 at 5:07 PM Martin Honnen martin.honnen@xxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> If you use Saxon 9.8 or 9.9 EE and streaming and for instance an
> `xsl:iterate` with an `xsl:break` then you will find that it indeed
> abandons parsing the input so non-wellformedness violations can go
> unnoticed.
>

I tried this with Saxon 9.9 EE, and observed results (for small enough
input XMLs) contrary to your claim. Below is my example,

Input XML (which is well-formed):

<?xml version="1.0" encoding="UTF-8"?>
<foo>
   <val>5</val>
   <val>4</val>
   <val>3</val>
   <val>0</val>
   <val>2</val>
   <val>0</val>
   <val>7</val>
</foo>

XSLT 3.0 stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

                        version="3.0">

    <xsl:output method="xml" indent="yes"/>

    <xsl:mode streamable="true"/>

    <xsl:template match="foo">
       <result>
          <xsl:iterate select="*">
            <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>

</xsl:stylesheet>

After the transformation, I get following output,

<?xml version="1.0" encoding="UTF-8"?>
<result>
   <mesg>hello</mesg>
   <mesg>hello</mesg>
   <mesg>hello</mesg>
</result>

When I change input document to following (deliberately making it
non-wellformed at the bottom),

<?xml version="1.0" encoding="UTF-8"?>
<foo>
   <val>5</val>
   <val>4</val>
   <val>3</val>
   <val>0</val>
   <val>2</val>
   <val>0</val>
   <val>
</foo>

With the same stylesheet, I now get following output,

Error on line 10 column 3 of foo.xml:
  SXXP0003: Error reported by XML parser: The element type "val" must be
terminated by the
  matching end-tag "</val>".
org.xml.sax.SAXParseException: The element type "val" must be terminated by
the matching end-tag "</val>".




-- 
Regards,
Mukul Gandhi

alt email : mukulgandhi@xxxxxxx

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.