Subject: Re: XSLT Question: Inserting a DOCTYPE decl From: "Steve Muench" <smuench@xxxxxxxxxxxxx> Date: Thu, 9 Dec 1999 19:07:30 -0800 |
<xsl:text disable-output-escaping="yes" ><[CDATA[<!DOCTYPE Numbers SYSTEM "<xsl:value-of select="$doctype"/>">]]></xsl:text> at the top of your root template, I think will do the job. _________________________________________________________ Steve Muench, Consulting Product Manager & XML Evangelist Business Components for Java Development Team http://technet.oracle.com/tech/java http://technet.oracle.com/tech/xml ----- Original Message ----- From: Roger L. Costello <costello@xxxxxxxxx> To: <xml-dev@xxxxxxxx>; Garriss Jr.,James P. <jgarriss@xxxxxxxxx>; Costello,Roger L. <costello@xxxxxxxxx> Sent: Thursday, December 09, 1999 1:00 PM Subject: XSLT Question: Inserting a DOCTYPE decl | Hi Folks, | | I have a situation where I have many XML documents that do not contain a | DOCTYPE declaration, and would like to write a stylesheet that inserts a | declaration within the documents. The interesting aspect of this | problem is that each XML document contains within it an element which | gives the name of the DTD file. So, the declaration should use the | value of that element as the name for the DTD file. | | For example, here's a sample XML document into which I need to insert a | DOCTYPE declaration: | | <?xml version="1.0"?> | <Numbers> | <DoctypeFile>Number.dtd</DoctypeFile> | <Number>27</Number> | <Number>34</Number> | <Number>18</Number> | <Number>67</Number> | <Number>99</Number> | <Number>16</Number> | </Numbers> | | Note the DoctypeFile element, which indicates the name of the DTD file. | | The stylesheet should insert the declaration, thus resulting in an XML | document as such: | | <?xml version="1.0"?> | <!DOCTYPE Numbers SYSTEM "Number.dtd"> | <Numbers> | <DoctypeFile>Number.dtd</DoctypeFile> | <Number>27</Number> | <Number>34</Number> | <Number>18</Number> | <Number>67</Number> | <Number>99</Number> | <Number>16</Number> | </Numbers> | | Here's the stylesheet that I wrote to do this task: | | <?xml version="1.0"?> | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | version="1.0"> | | <xsl:variable name="doctype"> | <xsl:value-of select="//DoctypeFile"/> | </xsl:variable> | | <xsl:output method="xml" doctype-system="string($doctype)"/> | | <xsl:template match="*|@*|comment()| | processing-instruction()|text()"> | <xsl:copy> | <xsl:apply-templates select="*|@*|comment()| | processing-instruction()|text()"/> | </xsl:copy> | </xsl:template> | | </xsl:stylesheet> | | A pretty simple stylesheet - create a variable which gets the value of | the DoctyleFile element, and instruct the xsl:output element to output a | DOCTYPE declaration, using the value of the variable as the name of the | DTD file, and then do a copy operation on the input XML document. | | Here is the XML file that I get when this example is run through XT | (Lotus XSL gives the same results): | | <?xml version="1.0"?> | <!DOCTYPE Numbers SYSTEM "string($doctype)"> | <Numbers> | <DoctypeFile>Number.dtd</DoctypeFile> | <Number>27</Number> | <Number>34</Number> | <Number>18</Number> | <Number>67</Number> | <Number>99</Number> | <Number>16</Number> | </Numbers> | | Note that the XSL processor did not evaluate the expression that I used | in the xsl:output's doctype-system attribute. Instead, it used the | expression literally. | | Thus, here are my questions: | | (1) Is this a bug in XT and Lotus XSL? | (2) I suspect it isn't a bug, in which case can someone think of | another way to solve this problem? | | /Roger | | | xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@xxxxxxxx | Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1 | To unsubscribe, mailto:majordomo@xxxxxxxx the following message; | unsubscribe xml-dev | To subscribe to the digests, mailto:majordomo@xxxxxxxx the following message; | subscribe xml-dev-digest | List coordinator, Henry Rzepa (mailto:rzepa@xxxxxxxx) | | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
combining multiple data sources, oliver . bruening | Thread | Re: XSLT Question: Inserting a DOCT, David Carlisle |
RE: Dynamically specifying the DTD, Ross Bleakney | Date | Antwort: combining multiple data so, thomas_harder |
Month |