HTML child elements - how to define

A

A Amitkashaw

Hello,

As a new guy to XML I'm stuck on (what I perceive as) a trickey problem. I'm
defining the element as so:

<!ELEMENT brains (#PCDATA)>

Within this element I have to be able to use HTML tags. XML being XML I can
either define every single HTML tag as a child or try and find a quick way
of doing it. I'd rather not have to define every single HTML tag that I
would like to use. From what I've defined I can have only text within the
tags BRAINS. I know there's a CDATA tag and <code> tags that can be used,
but can I use these within the ELEMENT tag to define *all* following HTML
tags?

Thanks for your time.

- S
 
P

Patrick TJ McPhee

% As a new guy to XML I'm stuck on (what I perceive as) a trickey problem. I'm
% defining the element as so:
%
% <!ELEMENT brains (#PCDATA)>
%
% Within this element I have to be able to use HTML tags.

If you want to validate against your DTD, you need to define all the
tags you're going to use. You can do this by including the XHTML
DTD, something like this:

<!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
%xhtml;

You can then define the content depending on what bits of xhtml you
need to use. For instance

<!ELEMENT brains (html)>

would allow (and require!) brains to include an entire html document.

<!ELEMENT brains (#PCDATA|html|%Block;)*>

would allow arbitrary text, an entire html document, or the content
model of the HTML body element.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top