xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 3.0 processor accepting non well-formed XML inputs

2019-03-02 23:35:47
Hi Martin,

On Fri, Mar 1, 2019 at 5:07 PM Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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(_at_)acm(_dot_)org
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>