Re: [xml] validating and xmlExternalEntityLoader's arguments

Date view Thread view Subject view Author view

From: Michael Mealling (michael@bailey.dscga.com)
Date: Mon Dec 04 2000 - 19:14:25 EST


On Mon, Dec 04, 2000 at 02:31:39PM +0100, Daniel Veillard wrote:
> On Sun, Dec 03, 2000 at 06:20:06PM -0500, Michael Mealling wrote:
> > I'm building a client application that will receive XML back from
> > several different servers which may decide to put different values in
> > thier SYSTEM identifier in their DOCTYPE. After poking around
> > trying to find an example of validatinog as you parsed (i.e.
> > xmlDoValidityCheckingDefaultValue = 1) it became obvious that
> > default behavior was to access whatever was in the SYSTEM ID regardless
> > of what the PUBLIC ID was. So I decided to write an ExternalEntityLoader.
> > Not finding an example of one I looked at the default one in xmlIO.c.
> > Its header looks like this:
> >
> > * xmlDefaultExternalEntityLoader:
> > * @URL: the URL for the entity to load
> > * @ID: the System ID for the entity to load
> > * @ctxt: the context in which the entity is called or NULL
> >
> > Is this correct?
>
> I think so except that ID is actually the PUBLIC id.

That's cool. I got all of this figured out but now I think
there might be a bug or else a problem in the reading of the XML spec.
I have a DTD that has this in it:

   <!ELEMENT results (status? |
                      ( service+,
                        ( status | resourcedescriptor | referral )*
                   )*
                  )>

and when I give it this:

<!DOCTYPE cnrp PUBLIC "-//IETF//DTD CNRP 1.0//EN" "http://www.ietf.org/cnrp.dtd">
<cnrp>
    <results>
        <service id="service1" ttl="10000">
            <serviceuri>http://cnrp.networksolutions.com>
        </service>
        <resourcedescriptor>
            <commonname>BAILEY BEAR</commonname>
            <id>8000112</id>
            <resourceuri>
http://bailey.dscga.com/>
            <serviceref ref="service1"/>
            <description>Michael and Kathy&apos;s Golden Retriever</description>
        </resourcedescriptor>
    </results>
</cnrp>

the parser barfs these errors:
Element results content doesn't follow the Dtd
Expecting (status? | (service+ , (status | resourcedescriptor | referral)*)*),
got (service resourcedescriptor )

Based on other parsers and my reading of the XML spec, that DTD
should allow that xml. Any clues as to why libxml tags that as an error?

Thanks!

-MM

The entire DTD:

   <!ELEMENT cnrp (query|results|servicequery)>
   <!ELEMENT servicequery EMPTY>
   <!ELEMENT query (id|(commonname,property*))>
   <!ELEMENT id (#PCDATA)>
   <!ELEMENT commonname (#PCDATA)>
   <!ELEMENT property (#PCDATA)>
   <!ATTLIST property name CDATA #REQUIRED>
   <!ATTLIST property type CDATA "freeform">
   <!ELEMENT results (status? |
                      ( service+,
                        ( status | resourcedescriptor | referral )*
                   )*
                  )>

   <!ELEMENT resourcedescriptor (commonname,id,resourceuri,
       serviceref, datasetref?,
       description,
       property*)>
   <!ATTLIST resourcedescriptor id ID #IMPLIED>

   <!ELEMENT resourceuri (#PCDATA)>
   <!ELEMENT description (#PCDATA)>

   <!ELEMENT referral (serviceref, datasetref?)>
   <!ATTLIST referral id ID #IMPLIED>

   <!ELEMENT status (#PCDATA)>
   <!ATTLIST status code CDATA #REQUIRED>
   <!ATTLIST status ref IDREF #IMPLIED>

   <!ELEMENT serviceref EMPTY>
   <!ATTLIST serviceref ref IDREF #IMPLIED>

   <!ELEMENT service (serviceuri, dataset*,
      servers?,
      description?,
      property*,propertyschema?,queryschema?,resourcedescriptorschema?,
      serviceschema?)>
   <!ATTLIST service ttl CDATA "0">
   <!ATTLIST service id ID #IMPLIED>
   <!ELEMENT serviceuri (#PCDATA)>
   <!ELEMENT servers (server+)>

   <!ELEMENT server (serveruri, property*)>
   <!ELEMENT serveruri (#PCDATA)>

   <!ELEMENT dataset (property*)>
   <!ATTLIST dataset id ID #IMPLIED>

   <!ELEMENT datasetref EMPTY>
   <!ATTLIST datasetref ref IDREF #IMPLIED>

   <!ELEMENT propertyschema (propertydeclaration*)>
   <!ELEMENT propertydeclaration (propertyname, propertytype*)>
   <!ATTLIST propertydeclaration id ID #IMPLIED>

   <!ELEMENT propertyname (#PCDATA)>
   <!ELEMENT propertytype (#PCDATA)>
   <!ATTLIST propertytype default (no|yes) "no">

   <!ELEMENT queryschema (propertyreference*)>

   <!ELEMENT resourcedescriptorschema (propertyreference*)>

   <!ELEMENT serviceschema (propertyreference*)>

   <!ELEMENT propertyreference EMPTY>
   <!ATTLIST propertyreference ref IDREF #REQUIRED>
   <!ATTLIST propertyreference required (no|yes) "no">

-- 
--------------------------------------------------------------------------------
Michael Mealling	|      Vote Libertarian!       | www.rwhois.net/michael
Sr. Research Engineer   |   www.ga.lp.org/gwinnett     | ICQ#:         14198821
Network Solutions	|          www.lp.org          |  michaelm@netsol.com
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Dec 04 2000 - 19:43:38 EST