Re: [xml] Degenerate case

2019-09-17 Thread Liam R E Quin
On Tue, 2019-09-17 at 09:26 -0400, Webb Scales wrote:
> Is it possible that the error message is wrong? 

Like most parsers, if given faulty input the output is sometimes
unexpected.

I'm not a maintainer here, but i'd guess that a patch to detect the
case of the document having no XML elements in it and give a better
error might well be accepted.

Liam


-- 
Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave beaten.

___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] Degenerate case

2019-09-17 Thread Webb Scales

Thank you for being so patient with me!

I did look at the XML grammar, but I only got far enough to suggest that 
the prolog was optional.  I should have continued on, but I was confused 
by the error message from LibXML2 ("Extra content at the end of the 
document") which seemed to indicate that it had (somehow) found a 
"document" and that it was then objecting to text coming after it.  I'm 
trying to take pains to ensure that the library is not presented with 
any text which isn't well-formed XML, so I'm trying to figure out what 
I've done wrong.


Is it possible that the error message is wrong?  (I concur that my text 
is erroneous, but it would be helpful if the error message were pertinent.)



 Thanks, again!

            Webb



On 9/17/19 1:45 AM, Liam R E Quin wrote:

On Tue, 2019-09-17 at 00:47 -0400, Webb Scales wrote:

Would a file containing just an XML comment, e.g.,




be an acceptable input to LibXML2?

Let's look at  the specification of XML,
https://www.w3.org/TR/REC-xml/

We see in section 2.1,
[[
  [Definition: A textual object is a well-formed XML document if:]

 Taken as a whole, it matches the production labeled document.

 It meets all the well-formedness constraints given in this
specification.

 Each of the parsed entities which is referenced directly or
indirectly within the document is well-formed.
]]

So we need our input to match Document.

The immediately following text in the spec has,
[[

Document
[1] document   ::=  prolog element Misc*
]]

If you follow these you find "element" means we need exactly one top-
level element, ..., and your example has a comment but no
element. So, it is not well-formed.

You will find it helpful to become moer familiar with the grammar in
the XML specification.

Best,

Liam




--

Webb Scales
Principal Software Architect
603-673-2306
www.ursasecure.com 
w...@ursasecure.com 

___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] Degenerate case

2019-09-16 Thread Liam R E Quin
On Tue, 2019-09-17 at 00:47 -0400, Webb Scales wrote:
> Would a file containing just an XML comment, e.g.,
> 
> 
> 
> 
> be an acceptable input to LibXML2?

Let's look at  the specification of XML,
https://www.w3.org/TR/REC-xml/

We see in section 2.1,
[[
 [Definition: A textual object is a well-formed XML document if:]

Taken as a whole, it matches the production labeled document.

It meets all the well-formedness constraints given in this
specification.

Each of the parsed entities which is referenced directly or
indirectly within the document is well-formed.
]]

So we need our input to match Document.

The immediately following text in the spec has,
[[

Document
[1] document   ::=  prolog element Misc*
]]

If you follow these you find "element" means we need exactly one top-
level element, ..., and your example has a comment but no
element. So, it is not well-formed.

You will find it helpful to become moer familiar with the grammar in
the XML specification.

Best,

Liam


-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


[xml] Degenerate case

2019-09-16 Thread Webb Scales

Would a file containing just an XML comment, e.g.,




be an acceptable input to LibXML2?
In my particular case, it's reacting with "Extra content at the end of 
the document", and I'm trying to determine whether it is due to some 
other factor in my specific scenario.



            Thanks!

                Webb



--

Webb Scales
Principal Software Architect
603-673-2306
www.ursasecure.com 
w...@ursasecure.com 

___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml