Displaying embedded html from an xml file through an xsl stylesheet

Discussion in 'XML' started by Joe Price, Sep 23, 2003.

  1. Joe Price

    Joe Price Guest

    Hi chaps

    I've got an XML file, within that file i've embedded html code using
    the
    <![CDATA[ ]]>
    tag

    I'm displaying that xml file through a browser using an xsl style
    sheet. However it is displaying any html from the xml file as text,
    ie its displaying as text <br/> and <b> etc

    How can i tell my xml file to display the html tags as html and not
    display them as text?

    Many thanks
    Joe Price, Sep 23, 2003
    #1
    1. Advertising

  2. Joe Price

    Martin Boehm Guest

    "Joe Price" <> wrote in message
    news:

    > I've got an XML file, within that file i've embedded html code using
    > the <![CDATA[ ]]> tag
    >
    > I'm displaying that xml file through a browser using an xsl style
    > sheet. However it is displaying any html from the xml file as text,
    > ie its displaying as text <br/> and <b> etc


    Sure, because the XSL Processor correctly escapes these tags, so they do
    not lose their (in this case textual) meaning in HTML.
    What you have to do is prevent this process called "output-escaping"
    from happening.

    When you have
    <native>
    <![CDATA[<p>Hallo</p><br><b>test</b>]]>
    </native>

    then this does the trick:
    <xsl:template match="native">
    <xsl:value-of disable-output-escaping="yes" select="."/>
    </xsl:template>

    HTH Martin
    Martin Boehm, Sep 23, 2003
    #2
    1. Advertising

  3. Joe Price

    Joe Price Guest

    cheers bud, worked a treat


    "Martin Boehm" <> wrote in message news:<3f7028e5$0$23098$-online.net>...
    > "Joe Price" <> wrote in message
    > news:
    >
    > > I've got an XML file, within that file i've embedded html code using
    > > the <![CDATA[ ]]> tag
    > >
    > > I'm displaying that xml file through a browser using an xsl style
    > > sheet. However it is displaying any html from the xml file as text,
    > > ie its displaying as text <br/> and <b> etc

    >
    > Sure, because the XSL Processor correctly escapes these tags, so they do
    > not lose their (in this case textual) meaning in HTML.
    > What you have to do is prevent this process called "output-escaping"
    > from happening.
    >
    > When you have
    > <native>
    > <![CDATA[<p>Hallo</p><br><b>test</b>]]>
    > </native>
    >
    > then this does the trick:
    > <xsl:template match="native">
    > <xsl:value-of disable-output-escaping="yes" select="."/>
    > </xsl:template>
    >
    > HTH Martin
    Joe Price, Sep 23, 2003
    #3
    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. Steven An
    Replies:
    1
    Views:
    486
    Martin Honnen
    Nov 23, 2004
  2. Thomas Sommer
    Replies:
    0
    Views:
    418
    Thomas Sommer
    Nov 25, 2004
  3. MC
    Replies:
    1
    Views:
    7,217
    David Carlisle
    Mar 24, 2005
  4. David Blickstein
    Replies:
    3
    Views:
    1,018
    David Blickstein
    Aug 2, 2005
  5. Replies:
    0
    Views:
    514
Loading...

Share This Page