Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > whitespace in MIXED tag

Reply
Thread Tools

whitespace in MIXED tag

 
 
andrew_nuss@yahoo.com
Guest
Posts: n/a
 
      02-18-2007
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

 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      02-18-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/

 
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
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM
To vlan tag or not to tag? budyerr Cisco 1 07-08-2004 03:45 AM



Advertisments