[xml2rfc] Re: Including ENTITIES

bortzmeyer at nic.fr (Stephane Bortzmeyer) Thu, 27 April 2006 05:03 UTC

From: "bortzmeyer at nic.fr"
Date: Thu, 27 Apr 2006 05:03:36 +0000
Subject: [xml2rfc] Re: Including ENTITIES
In-Reply-To: <026001c66972$b9247400$0400a8c0@china.huawei.com>
References: <026001c66972$b9247400$0400a8c0@china.huawei.com>
Message-ID: <20060427120327.GA5141@nic.fr>
X-Date: Thu Apr 27 05:03:36 2006

On Wed, Apr 26, 2006 at 04:48:07PM -0400,
 David B Harrington <dbharrington@comcast.net> wrote 
 a message of 39 lines which said:

> I am looking for a mechanism to "include" a text file (i.e., a MIB
> module that can run through a MIB compiler) into an xml2rfc document
> in a manner that is XML-valid

Use entities and preprocess your file with a program which knows how
to resolve them (like "xmllint --noent")?

% cat with-entities.xml 
<!DOCTYPE foobar [
<!ENTITY mibfile SYSTEM "mib.txt">
]>
<foo>The MIB: &mibfile;</foo>

% xmllint --noent with-entities.xml
<?xml version="1.0"?>
<!DOCTYPE foobar [
<!ENTITY mibfile SYSTEM "mib.txt">
]>
<foo>The MIB:    inetCidrRouteStatus OBJECT-TYPE
       SYNTAX     RowStatus
       MAX-ACCESS read-create
       STATUS     current
       DESCRIPTION
              "The row status variable, used according to row
               installation and removal conventions.

               A row entry cannot be modified when the status is
               marked as active(1)."
       ::= { inetCidrRouteEntry 17 }

</foo>
>From fenner at gmail.com  Thu Apr 27 11:53:51 2006
From: fenner at gmail.com (Bill Fenner)
Date: Thu Apr 27 10:53:58 2006
Subject: [xml2rfc] Re: Including ENTITIES
In-Reply-To: <20060427120327.GA5141@nic.fr>
References: <026001c66972$b9247400$0400a8c0@china.huawei.com>
	 <20060427120327.GA5141@nic.fr>
Message-ID: <ed6d469d0604271053v502d7d49u3aebc079510ad6de@mail.gmail.com>

On 4/27/06, Stephane Bortzmeyer <bortzmeyer@nic.fr> wrote:
> Use entities and preprocess your file with a program which knows how
> to resolve them (like "xmllint --noent")?

Only works if your MIB happens to be valid CharData.

[cavern:/tmp] fenner% xmllint --noent with-entities.xml
mib.txt:9: parser error : StartTag: invalid element name
              The character less-than (<) is going to cause
                                        ^
with-entities.xml:4: error: Failure to process entity mibfile
<foo>The MIB: &mibfile;</foo>
                       ^
with-entities.xml:4: parser error : Entity 'mibfile' not defined
<foo>The MIB: &mibfile;</foo>
                       ^
I tried David's suggested syntax with xmllint:

[cavern:/tmp] fenner% grep mib.txt with-entities.xml
<!ENTITY mibfile SYSTEM "mib.txt" NDATA mib>
[cavern:/tmp] fenner% xmllint --noent with-entities.xml
with-entities.xml:4: parser error : Entity reference to unparsed entity mibfile
<foo>The MIB: &mibfile;</foo>
                       ^

so, nothing obvious so far.  My obvious suggestion is to postprocess
mib.txt into mib.xml by escaping problem characters and use a parsed
entity inclusion, but that's an external step and I think David wanted
to avoid that.

  Bill