whitespace in MIXED tag

A

andrew_nuss

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
 
P

Peter Flynn

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
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top