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

Re: Need help rendering the HTML residing within the X

Subject: Re: Need help rendering the HTML residing within the XML
From: bry@xxxxxxxxxx
Date: Thu, 12 Aug 2004 10:08:19 +0200
jeremy graston
> First timer problem (couldn't find an exact answer in the archives): I 
> have an XML file with a hundred plus nodes of which any number could at 
> any time contain HTML tags such as the <b></b> tag in line 2.

The easiest way if you want to be able to use html anywhere is to define a html
namespace so

> 1 <book>
> 2 <name><b>Count of Monte Cristo</b></name>
> 3 <author>Alexander Dumas</author>
> 4 <content />
> 5 </book>

becomes 
> 1 <book xmlns:h="http://www.w3.org/1999/xhtml">
<!-- I'm referring to the xhtml namespace although that is not necessarily what
we will put out or accept as input -->
> 2 <name><h:b>Count of Monte Cristo</h:b></name>
> 3 <author>Alexander Dumas</author>
> 4 <content />
> 5 </book>
then have in your xslt the following template

<xsl:template match="h:*">
<xsl:element name="{local-name()}"><xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

I prefer that template to just doing a straight copy of because in that way you
can break out of copying at some lower level of a tree if necessary. 


the proper formatting of the b tags can then be controlled via a css. 


otherwise you can just have the following template for name

<xsl:template match="name">
<xsl:copy-of select="*"/>
</xsl:template>
that means of course that everything within name will have to be within a html
tag of some sort. 

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.