You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Julia Larson <Ju...@nativeminds.com> on 2001/08/29 23:38:23 UTC

DTD and DomParser

Please help a newbie who can't find it in the docs

How do I specify a DTD to use with a DomParser instance?

Where does it look for the dtd?  local directory?  
Does it need a fully qualified path?

Help!
Thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DTD and DomParser

Posted by Radovan CHYTRACEK <Ra...@cern.ch>.

Patrick Lok wrote:

> At 02:24 AM 8/30/01, you wrote:
> 
> 
>> Julia Larson wrote:
>>
>>> Please help a newbie who can't find it in the docs
>>> How do I specify a DTD to use with a DomParser instance?
>>
>>
>>
>> Supply a DOCTYPE, e.g. :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE myroot SYSTEM "myschema.dtd">
>> <myroot>
>> ...
>> </myroot>
> 
> 
> If the DOCTYPE is not in the document, is there a way to tell the 
> DOMParser to parse some dtd file before parsing the actual file?


I'm afraid that's not possible by defintion.

You can have either well formed standalone XML document without a DTD at all

or you supply the DTD file using DOCTYPE directive. If you say


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<myroot>
 ...
</myroot>

The XML parser in this case can check only whether the XML document

is well formed and that's it.

On the other hand in Xerces-C is possible to reuse DTD for multiple XML 
files which follow the same DTD definition. They can't have internal DTD 
subset in this case. Please look at the FAQ and/or archives for this topic.

Radovan

-- 

  Radovan Chytracek                  CERN Division IT/API, Geant4
  e-mail: Radovan.Chytracek@cern.ch  WWW: http://cern.ch/chytrace
  phone:  +41 22 76 78871



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DTD and DomParser

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Patrick Lok" <pl...@inktomi.com> writes:

> At 02:24 AM 8/30/01, you wrote:
> 
> 
> >Julia Larson wrote:
> >
> >>Please help a newbie who can't find it in the docs
> >>How do I specify a DTD to use with a DomParser instance?
> >
> >
> >Supply a DOCTYPE, e.g. :
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><!DOCTYPE myroot SYSTEM "myschema.dtd">
> ><myroot>
> >...
> ></myroot>
> 
> If the DOCTYPE is not in the document, is there a way to tell the
> DOMParser to parse some dtd file before parsing the actual file?

See the response that Julia posted to her own question. The
InputSource interface has both setPublicId() and setSystemId(). You
can apparently use these to create input sources and then set DTD's
for xml chunks without DOCTYPES.

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DTD and DomParser

Posted by Patrick Lok <pl...@inktomi.com>.
At 02:24 AM 8/30/01, you wrote:


>Julia Larson wrote:
>
>>Please help a newbie who can't find it in the docs
>>How do I specify a DTD to use with a DomParser instance?
>
>
>Supply a DOCTYPE, e.g. :
>
><?xml version="1.0" encoding="UTF-8"?>
><!DOCTYPE myroot SYSTEM "myschema.dtd">
><myroot>
>...
></myroot>

If the DOCTYPE is not in the document, is there a way to tell the DOMParser 
to parse some dtd file before parsing the actual file?


Thanks,
Patrick


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DTD and DomParser

Posted by Radovan CHYTRACEK <Ra...@cern.ch>.

Julia Larson wrote:

> Please help a newbie who can't find it in the docs
> 
> How do I specify a DTD to use with a DomParser instance?


Supply a DOCTYPE, e.g. :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE myroot SYSTEM "myschema.dtd">
<myroot>
...
</myroot>

> Where does it look for the dtd?  local directory?  
> Does it need a fully qualified path?


You can supply the fully qualified path or relative path.
In the example above it will search for the file myschema.dtd in the 
directory where the file is sitting.

Hope this helps

Radovan


-- 

  Radovan Chytracek                  CERN Division IT/API, Geant4
  e-mail: Radovan.Chytracek@cern.ch  WWW: http://cern.ch/chytrace
  phone:  +41 22 76 78871



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DTD and DomParser

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Julia Larson" <Ju...@nativeminds.com> writes:

> Please help a newbie who can't find it in the docs
> 
> How do I specify a DTD to use with a DomParser instance?
> 
> Where does it look for the dtd?  local directory?  
> Does it need a fully qualified path?

You don't. The XML file you are parsing specifies using the DOCTYPE,
either with PUBLIC or SYSTEM. Then it is up to an entity resolver to
find it and give it to the parser. 

jas.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org