Help! Parsing HTML inside XML with XSLT

Joined
May 13, 2004
Messages
4
Reaction score
0
Hi, I'm using OpenCMS and XML/XSLT to produce pages... The structure OpenCMS use for internal pages is something like this:

<[CDATA[<xml version="1.0" encoding="ISO-8859-1"?><root><title><b>A title</b></title></root>]]>

The desired effect I want to get is a page with "A title" in bold letters, so I use the following XSL:

<xsl:copy-of select="/root/title"/>

But I only get "A title" in normal letters (not bold), so it ignores "<b>" and "</b>"... Can anyone help me in the way of obtaining "A title" in bold letters... Thanks a lot.... I think the problem is the enclosing CDATA (because the same XML works just perfect transforming it locally with Xalan) but that's OpenCMS doing and I cannot take it off...
Any help appreciated...
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Miguel said:
I'm using OpenCMS and XML/XSLT to produce pages... The structure OpenCMS use for internal pages is something like this:

<[CDATA[<xml version="1.0" encoding="ISO-8859-1"?><root><title><b>A title</b></title></root>]]>

A CDATA section normally starts with <![CDATA[
The desired effect I want to get is a page with "A title" in bold letters, so I use the following XSL:

<xsl:copy-of select="/root/title"/>

But I only get "A title" in normal letters (not bold), so it ignores "<b>" and "</b>"... Can anyone help me in the way of obtaining "A title" in bold letters... Thanks a lot.... I think the problem is the enclosing CDATA (because the same XML works just perfect transforming it locally with Xalan) but that's OpenCMS doing and I cannot take it off...

Well if you have
<root><title><b>A title</b></title></root>
in your XML and want to transform that to HTML where the <b> element is preserved as the HTML <b> element which has the "bold" presentation meaning then you can use XSLT alike <xsl:template match="title"> <xsl:apply-templates /> </xsl:template> <xsl:template match="b"> <xsl:copy> <xsl:apply-templates /> </xsl:template> <xsl:template match="text"> <xsl:copy /> </xsl:template> and where you want to out the title element you use <xsl:apply-templates select="/root/title" />

But if you use CDATA sections to wrap XML markup then you will have a hard time to apply XSLT to that as XSLT only sees that as text and not as markup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top