[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how do I add a doctype when I create xsl from xsl?

Subject: Re: how do I add a doctype when I create xsl from xsl?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 05 Nov 2002 08:27:40 -0500
xslt add doctype
At 2002-11-05 12:59 +0000, solvej smith wrote:
I am using xslt to create one xsl from another xsl. How do I get this:

<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp '<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>'>

..placed in the top of the new xsl, that I am creating?

What you ask can be done (awkwardly), but perhaps you are unaware that what you are trying to do may not be necessary.

I'm assuming your new XSLT stylesheet will be outputing HTML since that is where most people are using the "nbsp" character entity reference.

According to XSLT 1.0 16.2 a processor is allowed to output a character entity reference if it recognizes the character as being one recognized by HTML processors.

If in your XSLT-generating XSLT you use &#160; for &nbsp;, then the stylesheet you create will use &#160; (or &#xa0; or &#xA0; instead) in the XML of that XSLT.

The processor you then use for your XSLT-generating XSLT may recognize during the serialization of the result tree in SGML lexical conventions following the HTML vocabulary that &#160; is &nbsp; and put out what you want in the final result of your generated stylesheet. Many of them do, though I concede they are not obliged to do so.

Is there a reason you wanted to see &nbsp; in the generated stylesheet? Who is your audience for the generated stylesheet?

Actually, is there a reason you wanted to see &nbsp; in the final transformed result? Who (as in human) is the audience for the bits and bytes of the source of transformed result? Since the processor is going to recognize the Unicode character anyway, why is the syntactic representation of the character important in your particular process? If your audience is only ever going to view the browsed result through a browser, why is the syntax of that result important enough to complicate your stylesheet writing?

These are important questions to ask in your design phase of your work.

BTW, when I have needed a static internal entity subset in my result and there is no DTD, I often put that subset into an external file and just reference it using the doctype-system= property of the xsl:output instruction. That would be the cleanest way to get what you want. The awkward way to get what you want would be to create the above text as a text node that itself is not escaped at the start of your result tree. Although this answers your question, I think you should be asking yourself why you are taking the approach you are taking in the first place.

I hope this helps.

....................... Ken

-- Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO: - North America: Feb 3 - Feb 7,2003

G. Ken Holman               mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.        http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                     Definitive XSLT and XPath
ISBN 0-13-140374-5                             Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1             Practical Formatting Using XSL-FO
Next conference training:                    2002-12-08,03-03,06

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.