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

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

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

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. Jarle Aase
    Replies:
    0
    Views:
    905
    Jarle Aase
    Nov 27, 2003
  2. Steven An
    Replies:
    1
    Views:
    709
    Martin Honnen
    Nov 23, 2004
  3. Thomas Sommer
    Replies:
    0
    Views:
    559
    Thomas Sommer
    Nov 25, 2004
  4. MC
    Replies:
    1
    Views:
    7,585
    David Carlisle
    Mar 24, 2005
  5. David Blickstein
    Replies:
    3
    Views:
    1,270
    David Blickstein
    Aug 2, 2005
  6. Replies:
    0
    Views:
    728
  7. confused
    Replies:
    3
    Views:
    553
    David Carlisle
    May 26, 2007
  8. confused
    Replies:
    3
    Views:
    590
    Pavel Lepin
    May 28, 2007
Loading...