Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Help! Parsing HTML inside XML with XSLT

Reply
Thread Tools

Help! Parsing HTML inside XML with XSLT

 
 
=?ISO-8859-15?Q?=22Miguel_J=2E_Jim=E9nez=22?=
Guest
Posts: n/a
 
      07-20-2004
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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-20-2004


Miguel J. Jiménez wrote:

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

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
parsing an inner Xml inside XML kris Java 3 01-10-2008 09:24 AM
Html to xml to my custom xml with xslt ??!? asd Java 0 12-09-2006 07:50 PM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
[XML::XSLT] empty result while parsing xml file PL Perl Misc 2 12-14-2004 10:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57