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

Re: XSLT Question: Inserting a DOCTYPE decl

Subject: Re: XSLT Question: Inserting a DOCTYPE decl
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Thu, 9 Dec 1999 19:07:30 -0800
xslt doctype declaration
<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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.