Subject: RE: several questions on XML to HTML processing with XSL From: Kay Michael <Michael.Kay@xxxxxxx> Date: Fri, 9 Jun 2000 14:35:37 +0100 |
> 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+. Define a global parameter, which you can set when the stylesheet is run: <xsl:param name="browser"/> e.g. you can set this from the command line as saxon my.xml my.xsl browser=IE5 > > <xsl:variable name="PageSection">DIV</xsl:variable> > <xsl:if test="$browser='NC4'> > <saxon:assign name="PageSection">LAYER</saxon:assign> > </xsl:if> You don't need <saxon:assign> here. Define a global variable as follows: <xsl:variable name="PageSection"> <xsl:choose> <xsl:when test="$browser='NC4'">LAYER</xsl:when> <xsl:otherwise>DIV</xsl:otherwise> </xsl:choose> </xsl:variable> > > <xsl:value-of select="<$PageSection ID='someID'>"/> > <!-- some HTML goes here --> > </xsl:value-of select="</$PageSection>"/> > What you want here is <xsl:element name="{$PageSection}"><!-- html --></xsl:element> Your suggested syntax is most imaginative but bears little relation to XSLT! > 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? <xsl:copy-of> is useful to achieve this effect. > > > 3. If I include an HTML tag as valid XML tag in my XML file, > how do I output > all attributes with their values? > E.g. I include <TABLE> in my XML file and I want to add (valid HTML) > attributes like width, height etc. which I > want to include in my HTML output. > What should be the appropriate XSL code? <xsl:copy-of select="."> copies the current element, its attributes, and its children, recursively. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: several questions on XML to HTM, Warren Hedley | Thread | RE: several questions on XML to HTM, H . vanderLinden |
Xpath and copy-of, Carlos Sanchez | Date | Re: several questions on XML to HTM, Warren Hedley |
Month |