xsl-list
[Top] [All Lists]

Re:semi-newbie question about escaping

2002-10-15 10:14:49
The goal here was to output some non-breaking space entities in HTML 
( ) to denote indentation.

The   entity isn't defined by default in XML. Your stylesheet needs 
to reference a DTD, or set up an internal subset, which provides that 
definition.

Alternatively, as others have said, use the numeric character reference 
rather than the mnemonic entity name. That should work everywhere   
does, and doesn't have to be explicitly defined.

Either way, if you can get the character into the data in the first place, 
HTML output mode will convert it to   on output. XML output mode may 
or may not do so, depending on whether you specified a DTD reference for 
the output and on the exact behavior of your XSLT processor's serializer; 
most won't, but I think it's allowed to do so if it wants to make the 
additional effort.

And either is better than trying to construct the entity reference as 
text. Among other things, if you ever want to pipe the XSLT processor's 
output directly into another XML application you'll find that the text 
approach will come through as text (equivalent to  ) whereas the 
character reference or the properly-defined entity reference will come 
through as the intended character.

______________________________________
Joe Kesselman  / IBM Research

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>