Re: [xsl] zero width no-break space to prevent tag minimisation

Subject: Re: [xsl] zero width no-break space to prevent tag minimisation
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 17 Oct 2008 11:44:26 -0400
Andrew,

At 04:27 AM 10/17/2008, you wrote:
> You've said you can't use the insert-a-comment workaround, although you
> haven't said why.

The comments are stripped out at a later stage, followed by more
stages of parsing/serialising which cause the then empty element to
use the empty element syntax...

I figured it was something like that.


> Would the reason you can't also preclude your using a similar hack, such as
>
> <div><span/></div>

Good idea... seems too simple :)  I'm trying to think back - why isn't
this the standard approach?  (why do we bother with inserting
comments, #160s etc?)

I think we generally prefer a comment because it best fits the implicit requirement of "do no harm" to the data. (I think the #160 thing probably hearkens back to the nbsp hack for common browsers' display of HTML tables, plus it's invisible while not subject to whitespace-stripping.)


Of course, the same reason comments do the least harm to the data is the reason why they don't always work -- since in some applications, like yours, they are considered by the same reasoning to add nothing, hence subject to stripping.

It's a good example of how the best solution is actually sensitive to the requirements -- "best" is relative. You have an edge case so what's usually best isn't best for you. (And what's an edge case for me might be normal for you -- something developers frequently forget. :-)

Another possibility to consider is plugging a nugatory PI in there as your doorstop:

<div><?open and close?></div>

-- which might be the in-between choice. (Dunno if your process drops PIs along with the comments.)

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread