Subject: Re: [xsl] methods of inserting html into output? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 25 Oct 2001 00:04:05 +0100 |
html in the output. So let me ask, "What are the various ways of inserting html/css/javascript into the output? When would you use each technique?" I seem to just write what I need an innovate when it doesn't work. Now I would like a more thorough understanding. This is what I come up with on first thought: 1) In-line literal elements into template body: <xsl:template ...> <tag> ... </tag> </xsl:template> USE WHEN SIMPLICITY IS NEEDED best never to use the word "tag" when discussing XML, but otherwise the answer is use this 99.99% of th etime. 2) Wrap in CDATA section <!--CDATA[ <tag> ... </tag> ]]> USE WHEN NEED TO PRESERVE INDENTATION IN OUTPUT? There's nothing simple about that. By using a CDATA section you are not inserting html nodes into the output tree, you are inserting a single text node with the linear representation of the html. If you then want to get that interpreted as html you have to use various non portable tricks using disable-output encoding that can't work in situations (such as client side mozilla transforms) where the output is not re-parsed but just passed as a DOM to the application. 3) <xsl:element> and <xsl:attribute> <xsl:element name="tag"> <xsl:attribute name="attr" value="value"/> </xsl:element> USE WHEN ? Use whenever you like, apart from some edge cases relating to namespace nodes (see the other current thread on this list) it is equivalent to (1) but takes up more space. Some people prefer it as a matter of style. 4) <xsl:text> USE WHEN? When you want to add text rather than elements 5) <xsl:comment> USE WHEN? When you want to add comments rather than elements 6), 7) ,8) ??? Can other add their advice? I'm not at all sure about the question. There is nothing HTML specific at all is there? The same would apply to any XML or HTML output language, as the whole point of XSLT is constructing the result tree, it would seem that answering your question would need listing every element in XSLT and describing its use? David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] methods of inserting html int, Steve Renshaw | Thread | Re: [xsl] methods of inserting html, Mike Brown |
Re: [xsl] ***********Transformation, David Carlisle | Date | RE: [xsl] using xsl to check for du, Pankaj Jain |
Month |