Reputation: 231
for my is necesary XHTML.
Then this is my DOCTYPE (code):
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html SYSTEM "http://myweb.com/DTD/prueba.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cosmos</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml;
charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="icon" href="https://myweb.com/graficos/favicon.ico"
type="image/x-icon" />
<style type="text/css">@import url("https://myweb.com/css/style.css");</style>
</head><body>
<div><planet>Jupiter!</planet></div>
</body></html>
and the code of "mydtd.tdt" is:
<!ELEMENT planet ANY>
<!ENTITY % html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
%html;
but validator.w3.org reply:
document type does not allow element "planet" here
I believe this answer is because the definition of element BODY of corse no't include the element "planet", I go to W3C and they say in https://www.w3.org/TR/xhtml-modularization/dtd_developing.html#sec_E.3.1.
" In the case of other elements that already have content models defined, the addition of an element would require the restating of the existing content model in addition to myelement. "
then I could edit my DTD following the instructions from W3C in: https://www.w3.org/TR/xhtml-modularization/dtd_developing.html#s_dtd_dev_elems " Basically, DTD authors should write the element declaration for each element: "
<!ATTLIST %MyModule.myelement.qname;
myattribute CDATA #IMPLIED
>
but really I unknow how fix my DTD for add my element/tag "planet", some help please?
Upvotes: 0
Views: 88
Reputation: 46559
To be able to insert a <planet>
element in an XML document, you need to tell the DTD where it can be inserted.
Technically this amounts to rewriting the whole DTD - since you need to tell each existing element that it can have new content - but fortunately the XHTML 1.1 DTD is modular, and all you need to do is redefine one of its entities before including it.
Assuming the new element is a phrasing element, insertable wherever things like <dfn>
, <cite>
etc can be inserted, we can use the InlPhras.class
entity to add the new element to.
<!ENTITY % InlPhras.class
"| em | strong | dfn | code | samp | kbd | var | cite | abbr | q | planet " >
Do this before including the XHTML 1.1 DTD in your DTD, so your whole file will look like this:
<!ENTITY % InlPhras.class
"| em | strong | dfn | code | samp | kbd | var | cite | abbr | q | planet " >
<!ELEMENT planet ANY>
<!ENTITY % html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
%html;
Then it'll work. And validate.
By the way, do you really want ANY
for a content model in the new element? This means it's legal to put any element inside it, even <body>
and <head>
. I don't think that's what you want.
Upvotes: 0