OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] DTD validation without a DOCTYPE

[ Lists Home | Date Index | Thread Index ]

At 2002-02-05 20:23 -0600, Caro, Samuel wrote:
>Is there a way to validate against a DTD if the xml file does NOT have a
>DOCTYPE?

Yes, there is a way of doing this entirely within XML 1.0 Recommendation 
without resorting to any proprietary functionality.

When I have to do this without munging the actual files themselves, I use 
parameter and general entities to effect the result.

I hope the example below helps.  Note how I can visually confirm the parts 
of the document by aligning the names of the document element type, DTD 
file, and the instance file.

Just create one of these XML instances for each combination of the three.

.................... Ken

T:\ftemp>type foo.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<foo>
   <bar/>
</foo>
T:\ftemp>type foo.dtd
<!ELEMENT foo ( bar )>
<!ELEMENT bar EMPTY>

T:\ftemp>type caro.xml
<!DOCTYPE  dummy-document-element [
<!ELEMENT  dummy-document-element      ( foo )>
<!ENTITY % dummy-document-dtd    SYSTEM "foo.dtd">
<!ENTITY   dummy-document-entity SYSTEM "foo.xml">
%dummy-document-dtd;
]>
<dummy-document-element>&dummy-document-entity;</dummy-document-element>

T:\ftemp>xml caro.xml
Processing: 'caro.xml' for XML errors

T:\ftemp>


--
Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:   2002-02-13,14,15,18,21,03-04,05,06,11,15,
-        04-08,09,10,11,05-06,07,09,10,14,15,06-04,07,10,11,13,14





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS