Is it just 'bad form'?

Discussion in 'XML' started by DFN-CIS NetNews Service, Jan 20, 2004.

  1. 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?

    --
    Stuart
    Tracers work both ways. - U.S. Army Ordnance
     
    DFN-CIS NetNews Service, Jan 20, 2004
    #1
    1. Advertising

  2. DFN-CIS NetNews Service wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 20, 2004
    #2
    1. Advertising

  3. 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.

    --
    Stuart
    Eat Healthy, Take Exercise, Die Anyway.
     
    DFN-CIS NetNews Service, Jan 20, 2004
    #3
  4. DFN-CIS NetNews Service

    Puff Addison Guest

    DFN-CIS NetNews Service wrote:

    >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 .


    --
    J. D. Addison
     
    Puff Addison, Jan 20, 2004
    #4
  5. 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.

    --
    Stuart
    If at first you don't succeed, skydiving is not for you.
     
    DFN-CIS NetNews Service, Jan 20, 2004
    #5
  6. DFN-CIS NetNews Service

    Puff Addison Guest

    DFN-CIS NetNews Service wrote:

    >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.



    --
    J. D. Addison
     
    Puff Addison, Jan 20, 2004
    #6
  7. DFN-CIS NetNews Service

    Andy Dingley Guest

    On Tue, 20 Jan 2004 10:29:49 +0000, DFN-CIS NetNews Service
    <> wrote:

    >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.



    --
    #1A1A1A is the new black
     
    Andy Dingley, Jan 21, 2004
    #7
  8. DFN-CIS NetNews Service

    Peter Flynn Guest

    Andy Dingley wrote:
    > On Tue, 20 Jan 2004 10:29:49 +0000, DFN-CIS NetNews Service
    > <> wrote:
    >
    >
    >>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.


    Pernicious mixed content only exists in SGML, not XML.

    ///Peter
     
    Peter Flynn, Jan 21, 2004
    #8
  9. DFN-CIS NetNews Service

    Andy Dingley Guest

    On Wed, 21 Jan 2004 01:26:41 +0000, Peter Flynn <>
    wrote:

    >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.
     
    Andy Dingley, Jan 21, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    888
  2. Eric Anderson

    Bad Transform or Bad Engine?

    Eric Anderson, Oct 4, 2005, in forum: XML
    Replies:
    1
    Views:
    378
    Peter Flynn
    Oct 5, 2005
  3. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    vs2005 publish website doing bad things, bad things

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    610
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Oct 25, 2006
  4. Gene

    Re: Bad code or bad compiler?

    Gene, Jun 1, 2008, in forum: C Programming
    Replies:
    3
    Views:
    285
    Barry Schwarz
    Jun 1, 2008
  5. rantingrick
    Replies:
    44
    Views:
    1,235
    Peter Pearson
    Jul 13, 2010
Loading...

Share This Page