Subject: [xml2rfc] xml2rfc XEP reference

From: Tom Pusateri <[email-masked]>
Date: Tue, 24 Feb 2015 13:39:42 -0500

I've been working on an internet draft that references an XMPP XEP for informational purposes. xml2rfc seems to be choking on the reference because it doesn't like the xml header. The error I am getting is:

(rfc)butte% xml2rfc draft-ietf-dnssd-llq.xml -o draft-ietf-dnssd-llq.txt --text
Parsing file draft-ietf-dnssd-llq.xml
ERROR: Unable to parse the XML document: draft-ietf-dnssd-llq.xml
 /Users/pusateri/.cache/xml2rfc/reference.XSF.XEP-0060.xml: Line 1: Space needed here
 draft-ietf-dnssd-llq.xml: Line 247: Failure to process entity XEP-0060
 draft-ietf-dnssd-llq.xml: Line 247: Entity 'XEP-0060' not defined

(rfc)butte% xml2rfc --version
2.4.8

(rfc)butte% head /Users/pusateri/.cache/xml2rfc/reference.XSF.XEP-0060.xml
<?xml version="1.0"?>
<reference anchor="XEP-0060">
  <front>
    <title>Publish-Subscribe</title>
    <author initials="P." surname="Millard" fullname="Peter Millard">
      <organization/>
      <address>
        <email/>
      </address>
    </author>

I've included this reference in my XML source as follows:

<!ENTITY XEP-0060 PUBLIC ""  "http://xmpp.org/extensions/refs/reference.XSF.XEP-0060.xml">

If I change the first line of the cached reference file from "<?xml version="1.0"?>" to "<?xml version='1.0' encoding='UTF-8'?>", it works fine.

Should xml2rfc be less picky about the first line or should the reference files on xmpp.org get updated or both?

Thanks,
Tom

---

From: Henrik Levkowetz <[email-masked]>
Date: Tue, 24 Feb 2015 21:08:15 +0100

Hi Tom,

On 2015-02-24 19:39, Tom Pusateri wrote:
> If I change the first line of the cached reference file from "<?xml
> version="1.0"?>" to "<?xml version='1.0' encoding='UTF-8'?>", it
> works fine.
> 
> Should xml2rfc be less picky about the first line or should the
> reference files on xmpp.org get updated or both?

As far as I can tell (based on http://www.w3.org/TR/REC-xml/#sec-prolog-dtd)
the lxml library which does the xml parsing is wrong in requiring the encoding.

I've tried various workarounds in the xml2rfc code this evening, but not managed
to find a way around this yet.  I'll be poking some more at it, but I'd suggest
you use your workaround in the meantime -- I can't promise a timely resolution.

Best regards,

	Henrik

---

From: Peter Saint-Andre - &yet <[email-masked]>
Date: Tue, 24 Feb 2015 14:44:01 -0700

On 2/24/15 11:39 AM, Tom Pusateri wrote:
> I've been working on an internet draft that references an XMPP XEP
> for informational purposes. xml2rfc seems to be choking on the
> reference because it doesn't like the xml header. The error I am
> getting is:
>
> (rfc)butte% xml2rfc draft-ietf-dnssd-llq.xml -o
> draft-ietf-dnssd-llq.txt --text Parsing file
> draft-ietf-dnssd-llq.xml ERROR: Unable to parse the XML document:
> draft-ietf-dnssd-llq.xml
> /Users/pusateri/.cache/xml2rfc/reference.XSF.XEP-0060.xml: Line 1:
> Space needed here draft-ietf-dnssd-llq.xml: Line 247: Failure to
> process entity XEP-0060 draft-ietf-dnssd-llq.xml: Line 247: Entity
> 'XEP-0060' not defined
>
> (rfc)butte% xml2rfc --version 2.4.8
>
>
> (rfc)butte% head
> /Users/pusateri/.cache/xml2rfc/reference.XSF.XEP-0060.xml <?xml
> version="1.0"?> <reference anchor="XEP-0060"> <front>
> <title>Publish-Subscribe</title> <author initials="P."
> surname="Millard" fullname="Peter Millard"> <organization/>
> <address> <email/> </address> </author>
>
> <!ENTITY XEP-0060 PUBLIC ""
> "http://xmpp.org/extensions/refs/reference.XSF.XEP-0060.xml">
>
>

The xmpp.org reference files need some attention in general so we can 
fix the encoding bit while we're at it.

Peter

-- 
Peter Saint-Andre
https://andyet.com/

---

From: "Martin J. Dürst" <[email-masked]>
Date: Wed, 25 Feb 2015 14:47:39 +0900

> the lxml library which does the xml parsing is wrong in requiring the encoding.

You have to be careful. I had to check it, too.

In a document entity (the main XML file), the XML declaration ("<?xml 
..."), if given, needs a version, but doesn't need an encoding. So on 
the main file, <?xml version="1.0"?> would be perfectly fine, as per 
http://www.w3.org/TR/REC-xml/#NT-XMLDecl.

However, for an external parsed entity (i.e. an included file, such as 
one with reference data), the text declaration (as with the XML 
declaration above, this starts with "<?xml ..."), if given, needs an 
encoding but not a version. Thus, <?xml encoding='UTF-8'?> would be 
fine, but <?xml version="1.0"?> wouldn't, as per 
http://www.w3.org/TR/xml/#NT-TextDecl.

This looks complicated. The way to remember it is to note that on small 
included snippets, the version will probably be irrelevant, but they can 
be in various different encodings.

If you want something to be usable both as a document entity (a document 
on its own) and an external parsed entity (a file to be included), then 
you either have to not have the "<!xml ..." stuff at the start or to 
make sure that it contains both version and encoding.

Regards,   Martin.

---

From: Henrik Levkowetz <[email-masked]>
Date: Wed, 25 Feb 2015 10:05:38 +0100

Hi Martin,

> http://www.w3.org/TR/xml/#NT-TextDecl.

Aha!

> be in various different encodings.

Seems reasonable; thanks for the mnemonic help.

> make sure that it contains both version and encoding.

Good guiding principle; thanks.

Best regards,

	Henrik