Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Constraining a mixed content model (XHTML <div>)

Reply
Thread Tools

Constraining a mixed content model (XHTML <div>)

 
 
Mark
Guest
Posts: n/a
 
      09-11-2005
In XHTML, several elements, such as <div>, may contain what's called
mixed content. Here's the mixed content model for <div>:

<!ELEMENT div (#PCDATA | %Block.class; | %Inline.class*>

%Block.class; includes several block-level (structural) elements, and
%Inline.class includes several inline-level (text) elements.

It can lead to strange results which are valid. For example, the
following is valid XHTML:

<div>
Some text.<p>Some more text.</p> And <i>more</i> text.
</div>


I'd like to constrain the DTD content model so <div> can have one
and only one of the following:

Either 1) (%Block.class)*
Or 2) (#PCDATA | %Inline.class*

(That is, the mixed content example given above will not validate to
the constrained DTD content model I'd like.)

For the desired constraint, does the following content model work?

<!ELEMENT div (((%Block.class)*) | ((#PCDATA | &Inline.class*))>

It seems correct to me, but I often get surprised when I play around
with complex DTD content models (and the above is not that complex --
some of them are absolutely horrid.)

Thanks!

Mark
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      09-13-2005
Mark wrote:

> In XHTML, several elements, such as <div>, may contain what's called
> mixed content. Here's the mixed content model for <div>:
>
> <!ELEMENT div (#PCDATA | %Block.class; | %Inline.class*>
>
> %Block.class; includes several block-level (structural) elements, and
> %Inline.class includes several inline-level (text) elements.
>
> It can lead to strange results which are valid. For example, the
> following is valid XHTML:
>
> <div>
> Some text.<p>Some more text.</p> And <i>more</i> text.
> </div>
>
>
> I'd like to constrain the DTD content model so <div> can have one
> and only one of the following:
>
> Either 1) (%Block.class)*
> Or 2) (#PCDATA | %Inline.class*


Unfortunately you can't do that in an XML DTD, only in an SGML one.

> (That is, the mixed content example given above will not validate to
> the constrained DTD content model I'd like.)
>
> For the desired constraint, does the following content model work?
>
> <!ELEMENT div (((%Block.class)*) | ((#PCDATA | &Inline.class*))>


No. In any nested content model containing PCDATA, the #PCDATA
must come first. XML Spec, 3.2.2 Mixed Content, [51].

> It seems correct to me, but I often get surprised when I play around
> with complex DTD content models (and the above is not that complex --
> some of them are absolutely horrid.)


Mixed content holds some suprises for the unwary
You may be able to fake this up in a Schema.

///Peter

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AccessDataSource constraining results? =?Utf-8?B?bXVzb3NkZXY=?= ASP .Net 3 02-22-2007 02:12 PM
problem with child text node when constraining other child node types Bryan Ax XML 6 05-17-2006 09:08 PM
Date with constraining facet minInclusive (timezone related) David Valera XML 0 05-10-2005 07:47 PM
Constraining the Datalist width. craigkenisston@hotmail.com ASP .Net 1 04-17-2005 09:42 AM
Bit length constraining integers & reals Kwaj VHDL 1 04-25-2004 02:12 PM



Advertisments