Help! Parsing HTML inside XML with XSLT

  • Thread starter =?ISO-8859-15?Q?=22Miguel_J=2E_Jim=E9nez=22?=
  • Start date
?

=?ISO-8859-15?Q?=22Miguel_J=2E_Jim=E9nez=22?=

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...

--
Miguel J. Jiménez
ISOTROL, S.A. (Área de Internet)
Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA)
mjjimenez AT isotrol DOT com --- http://www.isotrol.com
ICQ# 12670750
TLFNO. 955036800 ext. 111
 
M

Martin Honnen

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top