Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML DTD validation not working

42 views
Skip to first unread message

dustie

unread,
Jul 20, 2011, 9:48:36 AM7/20/11
to
Hi all

I've just got my first ever piece of PHP programming working so that it
imports an XML file and outputs everything from it accordingly.:)

The next thing I want to learn is all the strict stuff about well-formed
XML documents and including a Document Type Definition so that all the
data is rigidly maintained and no errors creep in. I've encountered a
problem though... I've setup a DTD file and am calling it from my XML
sheet, yet nothing whatsoever seems to be happening. I deliberately
included errors in the XML so that it would fail, yet the XML sheet is
getting called just as before and everything seems to be working fine

I then changed the 2nd line in the XML sheet to be this:

<!DOCTYPE test SYSTEM "blahblah.dtd">

..so that it's now calling a non-existent file. It still works fine so
the whole DTD bit is quite obviously getting ignored completely!

Any idea what I'm doing wrong?

Bjoern Hoehrmann

unread,
Jul 20, 2011, 11:38:03 AM7/20/11
to
* dustie wrote in microsoft.public.xml:

>The next thing I want to learn is all the strict stuff about well-formed
>XML documents and including a Document Type Definition so that all the
>data is rigidly maintained and no errors creep in. I've encountered a
>problem though... I've setup a DTD file and am calling it from my XML
>sheet, yet nothing whatsoever seems to be happening.

You are expecting an effect, but you do not say what you use to observe
the effect (or you loading the XML document in Internet Explorer, for
instance? Internet Explorer, when loading XML documents as if they were
HTML documents, does not validate by default). You have to use something
that can validate documents and then tell it to do so.
--
Björn Höhrmann · mailto:bjo...@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

Peter Flynn

unread,
Jul 21, 2011, 6:22:26 PM7/21/11
to
On 20/07/11 14:48, dustie wrote:
> Hi all
>
> I've just got my first ever piece of PHP programming working so that it
> imports an XML file and outputs everything from it accordingly.:)

Congratulations!

> The next thing I want to learn is all the strict stuff about well-formed
> XML documents and including a Document Type Definition so that all the
> data is rigidly maintained and no errors creep in.

Excellent idea.

> I've encountered a
> problem though... I've setup a DTD file and am calling it from my XML
> sheet,

One of the first things to master is the terminology. "XML sheet" isn't
anything defined in XML: do you mean an XSLT transformation (sometimes
called a "stylesheet"), or an XML document, or your PHP program, or
something else?

> yet nothing whatsoever seems to be happening.

We need to know (a) what you have done, and (b) what you want to do.

> I deliberately
> included errors in the XML so that it would fail, yet the XML sheet is
> getting called just as before and everything seems to be working fine
>
> I then changed the 2nd line in the XML sheet to be this:
>
> <!DOCTYPE test SYSTEM "blahblah.dtd">

If this is going to occur in an XML document it must be the first line.

> ..so that it's now calling a non-existent file. It still works fine so
> the whole DTD bit is quite obviously getting ignored completely!
>
> Any idea what I'm doing wrong?

If you are opening the XML document in a browser, it will ignore any
reference to a DTD because browsers do not support DTDs.

///Peter
--
XML FAQ: http://xml.silmaril.ie/


0 new messages