[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: several questions on XML to HTML processing with XSL

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
div in xsl
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.