whitespace in MIXED tag

Discussion in 'XML' started by andrew_nuss@yahoo.com, Feb 18, 2007.

  1. Guest

    Hi,

    Lets say I have a MIXED tag in my XML DTD with content that is going
    to be rendered as HMTL, as well as a <bold> and <italics> tag. What
    about whitespace? Specifically, does the whitespace in PCDATA of the
    MIXED tag get rendered into the output html? Or is it a setting in
    the XSL transforming document?

    Thanks,
    Andy
     
    , Feb 18, 2007
    #1
    1. Advertising

  2. Peter Flynn Guest

    wrote:
    > Hi,
    >
    > Lets say I have a MIXED tag


    element

    > in my XML DTD with content that is going to be rendered as HMTL, as
    > well as a <bold> and <italics> tag.


    I would strongly recommend that you don't call elements after
    appearances unless you are designing a DTD for describing typography
    (and even then probably not).

    > What about whitespace?


    Be careful.

    > Specifically, does the whitespace in PCDATA of the MIXED tag get
    > rendered into the output html? Or is it a setting in the XSL
    > transforming document?


    It's a pitfall. Yes, the white-space in mixed content does get preserved
    in the HTML serialization in XSLT, but only if you use the default
    setting of preserving space.

    If you use <xsl:strip-space elements="*"/> to "tidy up" the output
    serialization, irrelevant white-space is (correctly) suppressed between
    elements in element content, and is still preserved in mixed content
    *except* between adjacent elements (eg ...he said <italic>No</italic>
    <bold>NO</bold>") where it is classed as a white-space-only node and
    suppressed (omitted) so that you get...he said <i>No</i><b>NO</b>.

    This is an unfortunate side-effect of XML being minimally processable
    without a DTD or Schema (where element vs mixed content cannot be
    foretold), and is one of the very few pieces of bad design in XSLT
    because it happens *even* when the DTD is being used, which is precisely
    the circumstance when it should *not* happen (when element vs mixed
    content *is* foreknown).

    You will be told -- by people who should know better -- that XSLT must
    produce identical output whether run with or without a DTD/Schema, but
    this is untrue (for example, default attribute values may cause
    different output).

    As web browsers ignore all excess white-space anyway (except in <pre>
    elements), this shouldn't cause you any problems: just don't use
    strip-space until you are more familiar with the rules governing
    white-space nodes.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Feb 18, 2007
    #2
    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. jstack
    Replies:
    1
    Views:
    646
    Tor Iver Wilhelmsen
    Jul 4, 2003
  2. shruds
    Replies:
    1
    Views:
    938
    John C. Bollinger
    Jan 27, 2006
  3. Oli Filth
    Replies:
    9
    Views:
    3,365
    Uncle Pirate
    Jan 17, 2005
  4. Replies:
    10
    Views:
    800
    Eric Brunel
    Dec 16, 2008
  5. MRAB
    Replies:
    3
    Views:
    408
Loading...

Share This Page