Re: How to fix invalid XML?

45 views
Skip to first unread message

Bill Fenner

unread,
May 20, 2008, 10:56:14 AM5/20/08
to Philip Matthews, xml2rfc-...@googlegroups.com
On Tue, May 20, 2008 at 6:52 AM, Philip Matthews
<philip_...@magma.ca> wrote:
> XXE is complaining about the validity of my XML.
>
> It gives me two error messages, both of which say
> "the sequence of child elements is incorrect [cvc-complex-type.2.4]"
>
> The first one points at the Normative References section, and the
> second one at the Informative References section.
>
> I am guessing that the problem is that both of these sections only use
> <?rfc include="..." ?> directives. However, I am not clear how to fix
> this.

There isn't a way - since <?rfc include="..."?> is only a processing
instruction (not a real XML include construct), the file without
preprocessing *is* technically invalid. However, xxe will still work
fine, and xml2rfc will still work fine, so as long as these are the
only errors you don't have to worry about them.

Bill

David Harrington

unread,
May 20, 2008, 11:12:59 AM5/20/08
to xml2rfc-...@googlegroups.com, Philip Matthews
Hi,

If your only goal is to be compatible with XXE and xml2rfc, then <rfc
include> directives are fine. If you need to have valid XML for a
different editor, or other tools, then you might want valid XML.

An alternative that works in XXE and xml2rfc and is also technically
valid XML is to use ENTITY statements rather than <rfc include>
directives. This approach requires specifying what should be included
later in the document at places marked by &rfc3411; style markers.

See http://tools.ietf.org/tools/templates/mib-doc-template-xml.txt for
an example of this approach.

The <rfc include> directive approach may feel more natural for a
programmer that uses includes in their programming source files. The
ENTITY approach requires thinking of the problem slightly differently.

David Harrington
dbharr...@comcast.net
iet...@comcast.net
dharr...@huawei.com

Fred Baker

unread,
May 20, 2008, 12:10:16 PM5/20/08
to Philip Matthews, xml2r...@rtg.ietf.org

On May 20, 2008, at 6:52 AM, Philip Matthews wrote:

> I am guessing that the problem is that both of these sections only use
> <?rfc include="..." ?> directives. However, I am not clear how to fix
> this.

From the sound of it, that is exactly correct.

Yes, you can fix this. You do so by using the other form of include.
That, however, forces you to use xml2rfc exclusively when attached to
the network, as it goes to central locations to find the files. I use
the <?rfc form and keep a local cache of the reference files so that
I can use it at my leisure.

Philip Matthews

unread,
May 20, 2008, 2:43:32 PM5/20/08
to xml2rfc-...@googlegroups.com
Thanks to everyone who replied.
I have decided that I can live with the slightly-invalid XML.
Myself, I always use the on-line tool at xml.resource.org, but I write
documents at times with other authors, and I think the restriction
that Fred mentions below is serious. And it seems like the other
reference form is harder to use.

- Philip

Reply all
Reply to author
Forward
0 new messages