Subject: Re: [xsl] How to write data within DOCTYPE From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 6 Feb 2024 07:32:33 -0000 |
On Tue, 2024-02-06 at 06:45 +0000, Joga Singh Rawat jrawat@xxxxxxxxxxxxxx wrote: > Hi Team, > Could anyone of you let me know, how write data within DOCTYPE. > B > INPUT > <doc> > <bdy> > <img src="gr1.jpg"/> > <img src="gr2.jpg"/> > <img src="gr1.jpg"/> > </doc> This lacks a </bdy> tag and hence is not well-formed... > B > OUTPUT > <!DOCTYPE chapter SYSTEM "temp.dtd"[ > <!ENTITY gr1 SYSTEM "gr1" NDATA IMAGE> > <!ENTITY gr2 SYSTEM "gr2" NDATA IMAGE>]> > <chapter> > xxx > </chapter> Note that you can only use these NDATA entities in attribute values, not in general content. Having said that... you have several possible approaches to declare entities from within XSLT. It partly depends on which version of XSLT you're using, and in what environment. The simplest to understand is to use disable-output-escaping and write the internal subset yourself from XSLT: <xsl:template name="write-internal-subset"> <xsl:text disable-outputt-escaping="yes"><!DOCTYPE chapter SYSTEM "tmp.dtd" [</xsl:text> <xsl:call-template name="write-entities" /> <xsl:text disable-output-escaping="yes">]></xsl:text> </xsl:template> Not all XSLT processors support disable-output-escaping. A second way is to write the declarations to "tmp.dtd" using the "text" output method. You can use xsl:result-document to do this, with XSLT 2 or 3, or in XSLT 1 there are various extensions you can use, depending on which XSLT processor you are using. If your output XML is for use in a Web browser, they donbt handle NDATA entities. If you make the entity name be the same as the filename, then you write, e.g. <graphic image="gr1.jpg" /> and if the attribute is treated as a filename everything still works even if there is no DTD processing. liam -- Liam Quin,B https://www.delightfulcomputing.com/ Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to write data within DOCT, Joga Singh Rawat jra | Thread | [xsl] Are there XSLT processors tha, Roger L Costello cos |
[xsl] How to write data within DOCT, Joga Singh Rawat jra | Date | Re: [xsl] push data within doctype, Martin Honnen martin |
Month |