Click here to get back home

xhtml: adding ELEMENT to dtd

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
xhtml: adding ELEMENT to dtd Horace A. 'Kicker' Vallas 09-28-2007
Get Chitika Premium
Posted by Horace A. 'Kicker' Vallas on September 28, 2007, 1:00 pm
Please log in for more thread options
... or using multiple dtd's for doctype.

sorry if this is an infantile question - scouring an html to xhtml
conversion is not something I often do :-(

QUESTION:

does anyone know how we can add a new ELEMENT to an existing w3
dtd - or tell the doctype to add it or use an additional dtd in
the doctype etc. etc. etc.

BACKGROUND:

anyway - we have a pseudo tag we use for some indexing control on
a site - the tag-set is placed in the head section of an xhtml 1.0
transitional doc.

the w3 validator complains about the tag (and its attribute) when
it appears in the head section of the page - of course - but I
cannot seem to figure out how to add an element such that it will
be allowed in the head section.

have tried things like...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[
<!ELEMENT ourtag EMPTY>
        
        <!ATTLIST ourtag
                id                        CDATA        #REQUIRED
        >
]>

... and have even tried redefining the head element to include the
ourtag element etc.

nothing seems to work in a way that allows the validator to succeed

thanks!

p.s. - OH!! Hi y'all!! :-))

--
Horace ...once known as "Kicker" :-)
================================================================
...drop by and chat if I'm online http://www.hav.com/chat/
...or chuckle at a little left hand
fingertip torture http://www.hav.com/junk/

After silence, that which comes nearest to expressing the
inexpressible is music - Aldous Huxley, "Music at Night", 1931

... and that which comes nearest to explaining the inexplicable
is my insistence on trying to play it - hav '06 :-))
================================================================
Horace Vallas hav.Software http://www.hav.com/
4660 Francisco Rd. hav@hav.com
Pensacola, Fl. 32504
USA 850-207-7009

Thawte Web Of Trust Notary in Pensacola, Fl.
http://www.hav.com/?content=/thawteWOTnotary.htm
================================================================
What is a Vet? ... He is the barroom loudmouth, dumber than five
wooden planks, whose overgrown frat-boy behavior is outweighed a
hundred times in the cosmic scales by four hours of exquisite
bravery near the 38th parallel. ... - Unknown
================================================================

Posted by André Gillibert on September 28, 2007, 2:13 pm
Please log in for more thread options
Horace A. 'Kicker' Vallas wrote:


> QUESTION:
>
> does anyone know how we can add a new ELEMENT to an existing w3
> dtd - or tell the doctype to add it or use an additional dtd in
> the doctype etc. etc. etc.
>

You can create a custom external declaration subset file, derived from the
W3C one:
1) Download
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
2) Edit it to add your element:

<!ELEMENT ourtag EMPTY>
<!ATTLIST ourtag id CDATA #REQUIRED>
<!ENTITY % head.misc "(script|style|meta|link|object|isindex|ourtag)*">

3) Use a system identifier refering to your file in the document type
declaration. You may also define a registred or unregistred formal public
identifier.

Or, you may add these declarations in the internal declaration subset:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[
<!ELEMENT ourtag EMPTY>
<!ATTLIST ourtag id CDATA #REQUIRED>
<!ENTITY % head.misc "(script|style|meta|link|object|isindex|ourtag)*">
<!--
overrides the declaration contained in xhtml1-transitional.dtd
... Just hope that it won't be modified someday -->
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Extra element test!</title>
<ourtag id="id"/>
</head>
<body>
<p>Hello</p>
</body>
</html>

Of course, keep in mind that your page will be valid XML, but won't
conform to the XHTML 1.0 recommandation.
You mustn't expect normal user agents to render your page properly.
They may choke on this element. Most probably, they'll ignore it.

If you want to extend the XHTML language, you may also use XML namespaces.
The document won't be strictly conforming to the recommandation, but it
may at least be conforming.
XML namespaces are supposed to be the "normal" way of extending the
language.
http://www.w3.org/TR/xhtml1/#docconf

--

Posted by Horace A. 'Kicker' Vallas on September 28, 2007, 5:34 pm
Please log in for more thread options
hi Andre

And thanks! The second methid works fine and does allow the w3
validator to pass - but, when viewing pages, FF and IE display the
closing "]>" characters -- Opera looks fine and does not show
those two characters

I couldn't get the first method to work (meaning to pass the
validator) --- probably not pointing to the edited file correctly
or something

anyway - thanks again!

André Gillibert wrote:
> Horace A. 'Kicker' Vallas wrote:
>
>
>> QUESTION:
>>
>> does anyone know how we can add a new ELEMENT to an existing w3
>> dtd - or tell the doctype to add it or use an additional dtd in
>> the doctype etc. etc. etc.
>>
>
> You can create a custom external declaration subset file, derived from the
> W3C one:
> 1) Download
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
> 2) Edit it to add your element:
>
> <!ELEMENT ourtag EMPTY>
> <!ATTLIST ourtag id CDATA #REQUIRED>
> <!ENTITY % head.misc "(script|style|meta|link|object|isindex|ourtag)*">
>
> 3) Use a system identifier refering to your file in the document type
> declaration. You may also define a registred or unregistred formal public
> identifier.
>
> Or, you may add these declarations in the internal declaration subset:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
> [
> <!ELEMENT ourtag EMPTY>
> <!ATTLIST ourtag id CDATA #REQUIRED>
> <!ENTITY % head.misc "(script|style|meta|link|object|isindex|ourtag)*">
> <!--
> overrides the declaration contained in xhtml1-transitional.dtd
> ... Just hope that it won't be modified someday -->
> ]>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>Extra element test!</title>
> <ourtag id="id"/>
> </head>
> <body>
> <p>Hello</p>
> </body>
> </html>
>
> Of course, keep in mind that your page will be valid XML, but won't
> conform to the XHTML 1.0 recommandation.
> You mustn't expect normal user agents to render your page properly.
> They may choke on this element. Most probably, they'll ignore it.
>
> If you want to extend the XHTML language, you may also use XML namespaces.
> The document won't be strictly conforming to the recommandation, but it
> may at least be conforming.
> XML namespaces are supposed to be the "normal" way of extending the
> language.
> http://www.w3.org/TR/xhtml1/#docconf
>


--
Horace ...once known as "Kicker" :-)
================================================================
...drop by and chat if I'm online http://www.hav.com/chat/
...or chuckle at a little left hand
fingertip torture http://www.hav.com/junk/

After silence, that which comes nearest to expressing the
inexpressible is music - Aldous Huxley, "Music at Night", 1931

... and that which comes nearest to explaining the inexplicable
is my insistence on trying to play it - hav '06 :-))
================================================================
Horace Vallas hav.Software http://www.hav.com/
4660 Francisco Rd. hav@hav.com
Pensacola, Fl. 32504
USA 850-207-7009

Thawte Web Of Trust Notary in Pensacola, Fl.
http://www.hav.com/?content=/thawteWOTnotary.htm
================================================================
What is a Vet? ... He is the barroom loudmouth, dumber than five
wooden planks, whose overgrown frat-boy behavior is outweighed a
hundred times in the cosmic scales by four hours of exquisite
bravery near the 38th parallel. ... - Unknown
================================================================

Posted by André Gillibert on September 28, 2007, 6:27 pm
Please log in for more thread options
Horace A. 'Kicker' Vallas wrote:


> And thanks! The second methid works fine and does allow the w3
> validator to pass - but, when viewing pages, FF and IE display the
> closing "]>" characters -- Opera looks fine and does not show
> those two characters
>

With IE, there's no hope. IE doesn't support XHTML. It just supports HTML.
With FF, it should work if you ensure that the document is served with the
application/xhtml+xml MIME type with the HTTP protocol. With the text/html
MIME type, browsers won't parse it as XML.
For local files, use the .xml or .xhtml file extension, not the .html file
extension.

The XHTML support has issues in the real world. Even some geeks of
comp.infosystems.www.authoring.html admit that using HTML 4.01 strict is a
better idea.

> I couldn't get the first method to work (meaning to pass the
> validator) --- probably not pointing to the edited file correctly
> or something

Example:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC
"-//AndreSoft//DTD XHTML 1.0 Transitional plus ourtag//EN"
"http://files.myopera.com/SuperKoko/DTD/xhtml1-transitional-plus-ourtag.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ourtag test through custom external declaration subset</title>
<ourtag id="test" />
</head>
<body>
<p>This is a simple test.</p>
</body>
</html>

I uploaded the relevant file at:
http://files.myopera.com/SuperKoko/DTD/xhtml1-transitional-plus-ourtag.dtd

Storing new element type declarations in the external declaration subset
is better for compatibility with IE.
Using the internal declaration subset has side effects for tag-soup
parsers.

For important modifications of the XHTML 1.0 Transitional file, you may
have to copy and modify the xhtml1-transitional.dtd file itself.
In that case, read:
http://www.w3.org/Consortium/Legal/copyright-software-19980720

--

Posted by Jukka K. Korpela on September 28, 2007, 2:24 pm
Please log in for more thread options
Scripsit Horace A. 'Kicker' Vallas:

> ... or using multiple dtd's for doctype.

Huh? Continuing text from Subject line in body is bad style.

> sorry if this is an infantile question - scouring an html to xhtml
> conversion is not something I often do :-(

Good for you, but how does that relate to anything? I can't see anything
related to such a (pointless) conversion in your question.

> does anyone know how we can add a new ELEMENT to an existing w3
> dtd -

You add an element declaration for the element, and you modify the
declaration(s) of the element(s) in which the new element may appear,
according to its planned use.

There's a presentation of how to create and use custom DTDs at
http://www.cs.tut.fi/~jkorpela/html/own-dtd.html
though it's about SGML DTD's (but there's not that much difference between
them and XML DTD's, except that XML DTD's are more primitive).

Since you seem to understand the basics of DTD's, I guess the main point is
that you should create a copy of the DTD you want to use as the basis, edit
it, upload it on a www server, and refer to it with a URL in the DOCTYPE
declaration.

> or tell the doctype to add it or use an additional dtd in
> the doctype etc. etc. etc.

Ummm... no, that's not the way, really, but see below.

> anyway - we have a pseudo tag we use for some indexing control on
> a site - the tag-set is placed in the head section of an xhtml 1.0
> transitional doc.

Bad idea. Use a comment ("pseudocomment") or a <meta> tag, and you won't
need to modify the DTD.

> the w3 validator complains about the tag (and its attribute) when
> it appears in the head section of the page - of course - but I
> cannot seem to figure out how to add an element such that it will
> be allowed in the head section.

Why do you care? You can just ignore the messages that relate to the invalid
markup that you are using intentionally. If the invalid markup causes
problems in browsers or in search engines, it will do that quite
independently of DTD issues.

> have tried things like...
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
> [
> <!ELEMENT ourtag EMPTY>
>
> <!ATTLIST ourtag
> id CDATA #REQUIRED
>>
> ]>

That wouldn't help, since <ourtag> still wouldn't be allowed anywhere - no
element's content model allows it.

> ... and have even tried redefining the head element to include the
> ourtag element etc.

Well, yes, that's what you would need to do. But exactly what did you try?
You could use

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
[
<!ENTITY % head.misc "(script|style|meta|link|object|ourtag)*">
<!ELEMENT head (%head.misc;,
((title, %head.misc;, (base, %head.misc;)?) |
(base, %head.misc;, (title, %head.misc;))))>
<!ELEMENT ourtag EMPTY>
<!ATTLIST ourtag
id CDATA #REQUIRED
>
]>

(which allows <ourtag> elements anywhere in the <head> part - this might be
too permissive here)

and then the htmhelp.com validator passes a document a document using
<ourtag id="foo" >, though with some warnings. The W3C validator claims that
there are errors, partly because it treats a redeclaration as an error.

I'm too tired and too uninterested to check which one is right, but I
suspect the W3C validator might be wrong here. Does it matter?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Similar ThreadsPosted
Can TR element be direct child node of TABLE element? February 13, 2005, 12:17 pm
adding white space in

August 31, 2005, 4:34 pm
Adding video to my webpage July 29, 2007, 11:22 am
Adding custom attributes through XMLSchema November 4, 2005, 6:55 pm
Adding a text marker to TD elements with CSS September 16, 2008, 4:21 am
Help: Adding a banner to a site that uses "flanking menus", and CSS August 19, 2004, 6:00 am
Adding Data from FormMail to an Excel file February 14, 2005, 8:20 am
Adding Web form data to a new row of an excel file February 14, 2005, 8:51 am
div width in table cell adding extra space. July 28, 2004, 9:20 am
Table with Fixed Header not working after adding an onmouseover event February 2, 2006, 4:27 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap