<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>978</bug_id>
          
          <creation_ts>2004-12-30 11:30:27 +0000</creation_ts>
          <short_desc>systematic xml preparse mode triggers wrong parse mode for xml documents with broken xml declaration</short_desc>
          <delta_ts>2007-03-28 01:48:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Validator</product>
          <component>check</component>
          <version>0.6.7</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://qa-dev.w3.org/wmvs/HEAD/dev/tests/bogus-xmlpi.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>blocker</bug_severity>
          <target_milestone>0.8.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philipp Lucas">phlucas</reporter>
          <assigned_to name="Olivier Thereaux">ot</assigned_to>
          
          
          <qa_contact name="qa-dev tracking">www-validator-cvs</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2767</commentid>
    <comment_count>0</comment_count>
    <who name="Philipp Lucas">phlucas</who>
    <bug_when>2004-12-30 11:30:27 +0000</bug_when>
    <thetext>I am trying to convert a HTML 4.01 strict web page to XHTML. My first attempt 
apparently failed, but the validator does not tell me why. I stripped most 
content of the page, so that it consists now only of an XHTML skeleton.

&quot;This page is not Valid !
Below are the results of attempting to parse this document with an SGML parser.&quot;

... and that&apos;s it. Surely the validator should tell me the problem.

The page in question is http://rw4.cs.uni-sb.de/~phlucas/Lehre/semss05.xhtml.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2768</commentid>
    <comment_count>1</comment_count>
    <who name="Bj">bjoern</who>
    <bug_when>2004-12-30 15:27:10 +0000</bug_when>
    <thetext>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;&gt;

must be

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4209</commentid>
    <comment_count>2</comment_count>
    <who name="Terje Bless">link</who>
    <bug_when>2005-02-04 13:39:22 +0000</bug_when>
    <thetext>While we don&apos;t catch this error specifically, the current development code will,
due to other code changes, no longer produce empty results.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6804</commentid>
    <comment_count>3</comment_count>
    <who name="Olivier Thereaux">ot</who>
    <bug_when>2005-10-20 06:16:41 +0000</bug_when>
    <thetext>Update: latest release (0.7.1) still sends empty result, while 
current development code (HEAD, 0.8-dev) reports error
 beyond the boundaries of the document validated.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14052</commentid>
    <comment_count>4</comment_count>
    <who name="Olivier Thereaux">ot</who>
    <bug_when>2007-02-22 05:56:17 +0000</bug_when>
    <thetext>renaming, raising priority.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14527</commentid>
    <comment_count>5</comment_count>
    <who name="Olivier Thereaux">ot</who>
    <bug_when>2007-03-22 09:12:10 +0000</bug_when>
    <thetext>http://qa-dev.w3.org/wmvs/HEAD/check?uri=http%3A%2F%2Fqa-dev.w3.org%2Fwmvs%2FHEAD%2Fdev%2Ftests%2Fbogus-xmlpi.html;debug
is useful in understanding what&apos;s happening.

* an XHTML document is sent as text/html (curse the day text/html was said to be OK for XHTML...)
* the parse mode is set to TBD 
* preparse looks at document
  - by default HTML::Parser was set to XML mode
  - pre-parsing cannot find end of XML declaration, and thus parses the whole doc as if...
  - the doctype cannot be found
* as a result, XML mode is NOT triggered
* openSP is launched in SGML mode
* openSP parses the XML DTD as an SGML DTD, whines
* errors are reported in the DTD (which is why it looks as though it reports errors in the document, but at odd lines).

FIX: use pre-parser as XML mode only if the content-type has unambiguously shown that we should do so. 
In the case of text/html, cautiously use SGML pre-parsing. Finding an XHTML document type will later trigger xml mode in the actual parser and validator.

[[
my $p = HTML::Parser-&gt;new(api_version =&gt; 3);

- $p-&gt;xml_mode(TRUE);

+ # if content-type has shown we should pre-parse with XML mode, use that
+ # otherwise (mostly text/html cases) use default mode
+ $p-&gt;xml_mode(TRUE) if ($File-&gt;{Mode} eq &apos;XML&apos;);
]]

I have to test this patch against a number of other test cases, but I&apos;m hopeful it should be the solution to this problem, as well as Bug #14.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14528</commentid>
    <comment_count>6</comment_count>
    <who name="Olivier Thereaux">ot</who>
    <bug_when>2007-03-22 09:12:58 +0000</bug_when>
    <thetext>Assigning to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14558</commentid>
    <comment_count>7</comment_count>
    <who name="Olivier Thereaux">ot</who>
    <bug_when>2007-03-28 01:48:09 +0000</bug_when>
    <thetext>Patch mentioned in Comment #5 has been applied, and it works, as far as I (and my tests) can tell.
closing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>