Help! Parsing HTML inside XML with XSLT

Discussion in 'XML' started by =?ISO-8859-15?Q?=22Miguel_J=2E_Jim=E9nez=22?=, Jul 20, 2004.

  1. 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
     
    =?ISO-8859-15?Q?=22Miguel_J=2E_Jim=E9nez=22?=, Jul 20, 2004
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jul 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    761
    Stylus Studio
    Aug 3, 2004
  2. Replies:
    3
    Views:
    659
  3. kris
    Replies:
    3
    Views:
    1,688
  4. PL
    Replies:
    2
    Views:
    249
    Brian McCauley
    Dec 14, 2004
  5. Erik Wasser
    Replies:
    5
    Views:
    517
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page