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

Expanding DTD using inline declaration?

0 views
Skip to first unread message

Anthony Delorenzo

unread,
Mar 14, 2002, 10:39:17 PM3/14/02
to
Hello...

I'm using an XHTML doctype for some pages. I've added an attribute
to the <a> and <link> elements, and although this poses no problems
for user agents and/or non-validating parsers, my documents now
fail to validate according to doctype.

Can I extend the doctype with an inline declaration, and will this
satisfy a validating parser? (Could this also be done with a
second linked DTD?) Or would I have to modify the existing DTD?

Regards,
Anthony

--
Anthony DeLorenzo http://www.sfu.ca/~ajdelore/ ajde...@sfu.ca
...............................................................
"If they can get you asking the wrong questions, they don't have
to worry about answers." (Thomas Pynchon, Gravity's Rainbow)

Anthony Delorenzo

unread,
Mar 15, 2002, 12:48:17 AM3/15/02
to
>I'm using an XHTML doctype for some pages. I've added an attribute
>to the <a> and <link> elements, and although this poses no problems
>for user agents and/or non-validating parsers, my documents now
>fail to validate according to doctype.

I've solved this problem by extending the DTD using an internal
subset in the DOCTYPE statement. The problem I am facing now is
that most users agents don't correctly parse the DOCTYPE declaration
and it adversely affects the display of the page.

One solution is to modify the existing DTD -- however, this is a
standard W3C DTD that I would rather not edit, as it would involve
using a local (and therefore static) copy.

Is it possible to embed one DTD in another DTD using a link of some sort?
That is, could I
write an external DTD containing just the two extra declarations
and then somehow linking to the W3C external DTD?

Arjun Ray

unread,
Mar 15, 2002, 12:54:06 AM3/15/02
to
In <a6rqd5$6qn$1...@morgoth.sfu.ca>,
ajde...@sfu.ca (Anthony Delorenzo) wrote:

| I've added an attribute to the <a> and <link> elements, and [...]


| my documents now fail to validate according to doctype.

Actually, they fail to validate because the DTD is (in this case)
incomplete. ("According to doctype" is a common usage, but it doesn't
really make sense.)



| Can I extend the doctype with an inline declaration,

You have the right idea, but the wrong terminology (possibly because of
wrong concepts, see above.) The DTD is the *contents* of the document
type declaration. So, you can add the necessary declarations in the
internal subset on these lines:

<!DOCTYPE html PUBLIC "the usual mumbo-jumbo" [
<!ATTLIST a some-new-att CDATA #IMPLIED>
<!ATTLIST link another-new-att CDATA #IMPLIED>
]>

| and will this satisfy a validating parser?

Now your document should validate.

But!

You *can* do this, but serving this up to popular wowsers will have less
than optimal results, unless you can ensure that they pass your document
through an XML parser.

| (Could this also be done with a second linked DTD?) Or would I have to
| modify the existing DTD?

These are the same thing. You can construct the contents of the desired
DTD like this:

<!ENTITY % w3c-dtd PUBLIC "-//W3C//DTD XHTML etc etc" "url-I-forget">
%w3c-dtd;
<!ATTLIST a some-new-att CDATA #IMPLIED>
<!ATTLIST link another-new-att CDATA #IMPLIED>

Put these four lines in a file in your web-space, and make up a public
identifier to keep an XML parser happy. You can either just stick a URI
in the public identifier string, or ape the Formal Public Identifier
syntax like this:

"-//Your Company//DTD XHTML 1.0 Modified//EN"

(the XHTML specs have the exact details).

Now your document type declaration will look like this:

<!DOCTYPE html PUBLIC "Your Public Identifier" "url-to-your-DTD">

And again, the document should validate just fine, and wowsers will
survive the syntax too.

Anthony Delorenzo

unread,
Mar 15, 2002, 1:27:25 PM3/15/02
to
>These are the same thing. You can construct the contents of the desired
>DTD like this:
>
> <!ENTITY % w3c-dtd PUBLIC "-//W3C//DTD XHTML etc etc" "url-I-forget">
> %w3c-dtd;
> <!ATTLIST a some-new-att CDATA #IMPLIED>
> <!ATTLIST link another-new-att CDATA #IMPLIED>

Ah hah! This is exactly what I was looking for, your help is much
appreciated. I was slogging through the XML 1.0 specifications and
I suspected that I could use an ENTITY declaration, but I was never
able to clear up whether it could actually include another DTD
document or not.

In hindsight, this is probably better than using an internal subset
(even if the UA's would parse it properly) since changing multiple
DOCTYPE declarations would be a pain compared to keeping one
DTD up to speed.

Thanks again,

0 new messages