Re: [xsl] HTML entities

Subject: Re: [xsl] HTML entities
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2003 13:12:41 -0400

I'm sorry you found yourself heading down the literal-result-element-as-stylesheet rathole. As Mike said, the feature proves to be not all that useful. That's why none of these are FAQs.

At 12:17 PM 10/22/2003, you wrote:
Since the Simplified Syntax is actually useless
for producing real-life XHTML (no control over

That's not the only reason. A "Literal Result Element as Stylesheet" (not generally referred to as "Simplified Syntax" since it doesn't simplify much and doesn't change the syntax, just the organization of a stylesheet) must also be a stylesheet with a single template. This is next to useless for any real-world transformations of documentary data (such as you commonly make into HTML), since you are restricted to "pulling" data from the source into a fixed order. (For strictly ordered data sets it's not always unworkable.)

I am switching to the regular XSLT syntax.

Good: you won't be distracted any more by that particular garden path. :->

 Now my HTML entities need to be
declared somewhere.  Is there a standard template
for this?

By this I assume you mean declaring the entities to be used in the stylesheet. If your output comes with the correct DOCTYPE declaration, as you have noted, it will be taken care of by its own DTD.

I don't know of any "standard" way to pull HTML entities into your stylesheet, beyond simply pulling the relevant piece of the XHTML DTD in and declaring it for your stylesheet. (And it wouldn't be a template; it'd be a DTD module referred to in a DOCTYPE declaration for your stylesheet.)

I assume people are using XSLT to
produce HTML with editors that notice these sorts
of problems.  (I am using nxml emacs mode).

Many of us are content not to use named entity references in our stylesheets, or to declare locally only those that we need. The commonest HTML entity is probably &_nbsp; (no underscore) -- and this *is* a FAQ -- which can be easily gotten with the corresponding Unicode character reference, &_#160;. It works fine, no entity declaration is needed, and most HTML serializers will turn this into the &_nbsp; entity when they write the output file.

I sometimes have a DOCTYPE such as

<!DOCTYPE xsl:stylesheet [
<!ENTITY ldquo "&_#x201C;" ><!-- "&_#x201C;" =double quotation mark, left-->
<!ENTITY rdquo "&_#x201D;" ><!-- "&_#x201D;" =double quotation mark, right-->

[again, underscores inserted to fool "helpful" mailers]

...this is just so I don't have to memorize the funky Unicode points, but can use the named entity. But I don't bother with the entire HTML set -- only with the entities I am actually likely to need in my stylesheet.

Entities in the document are, of course, taken care of by the parser on input and serializer on output. Using them in your stylesheet has no bearing on this whatsoever; it's merely a convenience for the stylesheet author/maintainer.


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 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 ======================================================================

XSL-List info and archive:

Current Thread