[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: internal DTD-subset and CDATA-section
Hi Tobi, > what could I write in my XSLT to output the following > as part of the result: > > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" > "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" > [ > <!ENTITY fast-slow "0 0 .5 1"> > <!ENTITY slow-fast ".5 0 1 1"> > ]> > <svg > xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd" > xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 > 0 800 600"> > <style type="text/css"> > <![CDATA[ > .balls {font: 30pt arial} > ]]></style> You can set the DOCTYPE declaration and the fact that you want to use a CDATA section (although as David C. said, there's no point in having one with the example as shown) using the xsl:output element: <xsl:output doctype-public="-//W3C//DTD SVG 20001102//EN" doctype-system="http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" cdata-section-elements="style" /> However, this doesn't allow you to define an internal subset in the way that you have. Using pure XSLT, you have to do this using disable-output-escaping: <xsl:text disable-output-escaping="yes"><![CDATA[ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" [ <!ENTITY fast-slow "0 0 .5 1"> <!ENTITY slow-fast ".5 0 1 1"> ]> ]]></xsl:text> (Saxon has some support for creating internal DTD subsets.) There's no much point in defining entities unless you're going to use them, so presumably you'll also want to create entity references within your output. Again, you have to disable output escaping to ensure that the entities are used: <xsl:text disable-output-escaping="yes">&fast-slow;</xsl:text> (Or you can use saxon:entity-ref.) Note that you cannot use disable-output-escaping to put the entity reference in as an attribute value. There is no way of doing that in XSLT. Having said that, you should be careful using disable-output-escaping. You cannot guarantee that a processor will understand it or use it. Generally, you should not care about using entities in your output - you should just generate the text that you want. To create the namespace declarations, you just have to have the svg element created somewhere where the namespace declarations are in scope. For example: <svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 800 600"> ... </svg> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|