Is it just 'bad form'?

  • Thread starter DFN-CIS NetNews Service
  • Start date
D

DFN-CIS NetNews Service

I don't seem to see the following structure very often ...

<root>
<e1>this
<e2/>
<e3>that</e3>
</e1>
</root>

That is an element with text /and/ child nodes.

Is this just bad form? I know it is OK technically but are there
practical reasons for avoiding doing it?
 
M

Martin Honnen

DFN-CIS NetNews Service said:
I don't seem to see the following structure very often ...

<root>
<e1>this
<e2/>
<e3>that</e3>
</e1>
</root>

That is an element with text /and/ child nodes.

Is this just bad form? I know it is OK technically but are there
practical reasons for avoiding doing it?

Well, with a DTD suched mixed content is hard to restrict. Of course if
you look at XHTML container elements they need to allow such content but
even there the different document types make different restrictions, for
instance with the XHTML 1.0 transitional document type the <body>
element is defined as
<!ELEMENT body %Flow;>
where The Flow entity is defined as
<!ENTITY % Flow "(#PCDATA | %block; | form | %inline; | %misc;)*">
which is the mixed content of text and markup elements.
With the XHTML 1.0 strict document type <body> is defined as
<!ELEMENT body %Block;>
so there no mixed content is allowed, only block elements can be direct
children of the <body>.
With XHTML strict the reasons for that are that they want you to write
clean structured documents where you use proper container block elements
with the right semantics (for instance a <p> element) to wrap your text
content.
Thus looking at that you could say it is bad (but established form) to
have mixed content in every elements but a few selected ones.

As for your example if <e1> contains sentences in some human language
and <e2 /> is some empty element like an <img> element in XHTML and <e3>
is semantically necessary to mark up a part of a sentences contained in
<e1> then it is certainly not bad form but if <e1> contains different
data nodes then I would say that it is bad style to have some data in a
text node and some in element nodes.
 
D

DFN-CIS NetNews Service

On 20/01/2004, around 11:09, Martin Honnen wrote:

MH> Well, with a DTD suched mixed content is hard to restrict. Of course if
MH> you look at XHTML container elements they need to allow such
MH> content...
[deletia]

Interesting, thanks. In my case I'm talking about XML data rather than
XHTML, but that was useful.

TVM.
 
P

Puff Addison

DFN-CIS NetNews Service said:
I don't seem to see the following structure very often ...

<root>
<e1>this
<e2/>
<e3>that</e3>
</e1>
</root>

That is an element with text /and/ child nodes.

Is this just bad form? I know it is OK technically but are there
practical reasons for avoiding doing it?
It rather depends on what you are using the XML for.
If it is "data-centric" , so being used to show the structure of some
data then it is probably bad form/ poorly designed ;
but if the use is "docu-centric" and so being used to show the mark up
and structure of a visible/readable document where one has a mix of
plain text , graphics and emphasis then it seems quite natural .
 
D

DFN-CIS NetNews Service

On 20/01/2004, around 11:33, Puff Addison wrote:

PA> If it is "data-centric" , so being used to show the structure of some
PA> data then it is probably bad form/ poorly designed ;
That's precisely it; it /feels/ bad but I can't get a handle on why we
shouldn't be doing it.

I'd rather see something like

<root>
<e1>
<e1_text>this</e1_text>
<e2/>
<e3>that</e3>
</e1>
</root>

IYSWIM.
 
P

Puff Addison

DFN-CIS NetNews Service said:
On 20/01/2004, around 11:33, Puff Addison wrote:

PA> If it is "data-centric" , so being used to show the structure of some
PA> data then it is probably bad form/ poorly designed ;
That's precisely it; it /feels/ bad but I can't get a handle on why we
shouldn't be doing it.

I'd rather see something like

<root>
<e1>
<e1_text>this</e1_text>
<e2/>
<e3>that</e3>
</e1>
</root>

IYSWIM.

Yes. I see what you mean.
If you are creating the mark up then you are free do it that way. But it
is not clear to me that you get any real benefit
unless e1_text is to have some structure of its own but you do add to
the overhead of document creation.
Think of paragraph a number of words or phrases in bold or italic or
courier. Every time I need to add a new e1_text element as well.
 
A

Andy Dingley

I don't seem to see the following structure very often ...

I see it a lot, and a damn nuisance it is too.

What are you storing here ? An XML tree structure of "data items",
with leaf nodes that contain a string ? Or a text document, with
embedded markup ?

If it's the first, then avoid this as far as you can. It causes all
sorts of trouble.

If it's the second (which includes (X)HTML) then it's hard to avoid
it. It's possible to avoid it, but only by making the DTD
significantly more complex, to an impractical degree. In the DocBook
world it's known as "pernicious mixed content" and is subject to much
debate.
 
P

Peter Flynn

Andy said:
I see it a lot, and a damn nuisance it is too.

What are you storing here ? An XML tree structure of "data items",
with leaf nodes that contain a string ? Or a text document, with
embedded markup ?

If it's the first, then avoid this as far as you can. It causes all
sorts of trouble.

If it's the second (which includes (X)HTML) then it's hard to avoid
it. It's possible to avoid it, but only by making the DTD
significantly more complex, to an impractical degree. In the DocBook
world it's known as "pernicious mixed content" and is subject to much
debate.

Pernicious mixed content only exists in SGML, not XML.

///Peter
 
A

Andy Dingley

Pernicious mixed content only exists in SGML, not XML.

Sorry - I should have been clearer.

DocBook is an SGML standard that moved to XML (is it the only major
standard that did this ?). When it was in SGML, then pernicious mixed
content was a real problem. It's still worth reading up on, because
the problem is still there, just watered down. "Pernicious mixed
content" is a more useful search term than "mixed content" for
finding it.
 

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

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top