Jump to content

Simple (Newbie) Question About Processing Xml & Dtd With A Browser


RoyT

Recommended Posts

It appears that browsers will process internal DTDs but will not read them in a separate file. Please clarify what is going on here. The css is read and processed just fine. The important problem for me is the failure to recognize the ENTITY definition. I appreciate any help. person.dtd=========<!ELEMENT person (first_name, profession)<!ELEMENT first_name (#PCDATA)<!ELEMENT profession (#PCDATA)<!ENTITY ndash "–">person.css=========first_name{ display: block; font-family: "Times New Roman", serif; font-weight: bold; font-size: 10pt;}profession{ display: block; font-family: "Times New Roman", serif; font-style: italic; font-size: 10pt;}person.xml=========<?xml version="1.0"?><?xml-stylesheet type="text/css" href="person.css"?><!-- the following does not work --><!DOCTYPE person SYSTEM "person.dtd"><!-- the following works --><!--<!DOCTYPE person [ <!ENTITY ndash "–">]>--><person> <name> <first_name>Alan</first_name> </name> <profession>computer–scientist</profession></person>

Link to comment
Share on other sites

You have the syntax wrong in your DTD file. You're missing closing angle brackets: <!ELEMENT person (first_name, profession)><!ELEMENT first_name (#PCDATA)><!ELEMENT profession (#PCDATA)><!ENTITY ndash "–">

Link to comment
Share on other sites

Thank you for looking at this, but that fix did not change the failure: XML Parsing Error: undefined entityLocation: file:///home/rtouzeau/Documents/Calendar-Sheets/CSS-Play/person.xmlLine Number 17, Column 23: <profession>computer–scientist</profession>----------------------^ I have spent a LOT of time looking at ref manuals and twisting this code every way I could think of.

Link to comment
Share on other sites

Ok, here we go. The – shows up now. First is "person.dtd" and following is "person.xml" <!ELEMENT person (first_name, profession)><!ELEMENT first_name (#PCDATA)><!ELEMENT profession (#PCDATA)><!ENTITY ndash "–"><?xml version="1.0"?><?xml-stylesheet type="text/css" href="person.css"?><!-- the following does not work --><!DOCTYPE person SYSTEM "person.dtd"><!-- the following works --><!--<!DOCTYPE person [ <!ENTITY ndash "–">]>--><person> <name> <first_name>Alan</first_name> </name> <profession>computer–scientist</profession></person>

Link to comment
Share on other sites

Let me try this...<?xml version="1.0"?><?xml-stylesheet type="text/css" href="person.css"?><!-- the following does not work --><!DOCTYPE person SYSTEM "person.dtd"><!-- the following works --><!--<!DOCTYPE person [ <!ENTITY ndash "–">]>--><person> <name> <first_name>Alan</first_name> </name> <profession>computer–scientist</profession></person>

Link to comment
Share on other sites

I'm just testing now on my computer. It's not working for me either, though it should in theory. The only conclusion I get is that the doctype isn't loading the DTD file for some reason.

Link to comment
Share on other sites

I just got this from the Mozilla Developer Network:

Mozilla does not load external entities from the web. Mozilla can load external entities whose system identifier uses the chrome protocol. This feature is used mainly to localize Mozilla to different languages (the UI strings are stored in external DTD files). Another exception is an entity whose system identifier is a relative path, and the XML declaration states that the document is not standalone (default), in which case Mozilla will try to look for the entity under <bin>/res/dtd directory.
It means that you have to declare your entities inside the XML document.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...