Subject: Re: several questions on XML to HTML processing with XSL From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx> Date: Fri, 09 Jun 2000 09:37:56 -0400 |
H.vanderLinden@xxxxxxxxxxxxx wrote: > > 1. I want to output <LAYER ID='something'><!-- some HTML goes here > --></LAYER> when I find the browser is > Netscape 4+ and <DIV ID='something'><!-- some HTML goes here --></DIV> when > the browser is Internet Explorer 4+. <xsl:template match="some_div-like_element"> <xsl:choose> <xsl:when test="$browser = 'NC4'"> <div ID='{whatever}'> <xsl:apply-templates /> </div> </xsl:when> <xsl:otherwise> <layer ID='{whatever}'> <xsl:apply-templates /> </layer> </xsl:otherwise> </xsl:choose> </xsl:template> > 2. I want to allow (well-formed) HTML in my XML file which I want to output > as is in my HTML file, how should I go about? E.g. I want this in my XML > file and out to HTML in the same way: You've probably got the wrong end of the stick here. If you use the HTML output method, then a conformant XSLT processor (like Saxon) will convert your well-formed XML into the abbreviated HTML syntax with which browsers are familiar. Putting the following at the top of your stylesheet <xsl:output method="html"> turns <img src="img.jpg" /> into <img src="img.jpg"> and <br /> into <br>. If you really need to put some markup directly into your output document you could consider using CDATA sections, but this is not the "right" way to do things. <xsl:text><![CDATA[<IMG src='img.jpg'>]]></xsl:text> > 3. If I include an HTML tag as valid XML tag in my XML file, how do I output > all attributes with their values? Use <xsl:copy-of ... />. You must copy your attributes across before you start on the element content. <xsl:template match="table|img|..."> <xsl:copy> <!-- create start tag for current element --> <xsl:copy-of select="@*" /> <!-- copy attributes --> <xsl:apply-templates /> </xsl:copy> </xsl:template> Hope this helps. -- Warren Hedley XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
several questions on XML to HTML pr, H . vanderLinden | Thread | RE: several questions on XML to HTM, Kay Michael |
RE: several questions on XML to HTM, Kay Michael | Date | Wanted: Extension functions using D, Kay Michael |
Month |