Re: how do I add a doctype when I create xsl from xsl?
I am using xslt to create one xsl from another xsl. How do I get this:
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   for , then the stylesheet you create will use   (or   or   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   is 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 in the generated stylesheet? Who is your audience for the generated stylesheet?
Actually, is there a reason you wanted to see 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.
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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format