469,609 Members | 1,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Display embedded html tags in an xml file (element data, not attributes) using xsl

Hi all, I know this is a well-worn topic, but in viewing multiple posts
and articles, I still can't find a satisfactory answer.

I have embedded html in an xml file (element data, not attributes)
which I wish to display.

--example of xml doc
<footnotes type_num="5">
<footnote footHeaderValue="0" sub="0" br="0"
b="0"><company/><sup></sup> is authorized to transact business in all
U.S. states and the District of Columbia. Product availability varies
by state. <a href="http://www.xxxl.com/copyright"> Copyright 2002</a>
All rights reserved.
</footnote>

I want to display/translate the above with html links intact (and other
formatting if possible)

I am using embedded tags (<company/>) which I am matching and replacing
this data from the xml file. These are working fine, but the html is
not displaying.

-- example of embedded template for company
<xsl:template match="company" name="company_name">
<xsl:value-of select="//company"/>
</xsl:template>
-- example for outputing xml snipit
<xsl:for-each select="footnotes[@type_num = 10]/footnote">
<div class=".dynamicPageParagraph">
<p>
<xsl:apply-templates select="." />
</p>
</div>
</xsl:for-each>

Really appreciate any help

Apr 19 '06 #1
5 7347
> I want to display/translate the above with html links intact (and other
formatting if possible)


You could use <xsl:copy-of> instead of <xsl:value-of>.

The problem is that in your case, it is probably not very clean to have the
HTML-nodes being part of the XML-document. So you should probably write the
HTML inside <![CDATA[ ... ]]> or escape the special characters by their
respective entities (&lt; instead of <, etc.). You can then output the HTML
using <xsl:value-of disable-output-escaping="yes"/>, which should just
output the plain contents of your selection and not escape special
characters by their entities (I think).
Apr 19 '06 #2
iegeek write:
I want to display/translate the above with html links intact (and other
formatting if possible)

Felix Engelhardt wrote: The problem is that in your case, it is probably not very clean to have the
HTML-nodes being part of the XML-document.
Yes, the OP should use namespaced XHTML within his XML document.
So you should probably write the
HTML inside <![CDATA[ ... ]]> or escape the special characters by their
respective entities (&lt; instead of <, etc.).
Argh
You can then output the HTML
using <xsl:value-of disable-output-escaping="yes"/>, which


.... is optional by specification.

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Apr 19 '06 #3
Johannes Koch wrote:
Yes, the OP should use namespaced XHTML within his XML document.


Yes. Or even just XML using the HTML tag set, with the stylesheet set up
so those are passed through appropriately.
So you should probably write the HTML inside <![CDATA[ ... ]]> or
escape the special characters by their respective entities (&lt;
instead of <, etc.).


Argh


Seconded. That's always a bad solution.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Apr 19 '06 #4
iegeek wrote:
Hi all, I know this is a well-worn topic, but in viewing multiple posts
and articles, I still can't find a satisfactory answer.

I have embedded html in an xml file (element data, not attributes)
which I wish to display.


FAQ. See http://xml.silmaril.ie/authors/html/

///Peter
Apr 19 '06 #5
Thank you all for you help and input. the 'copy-of' did the trick.
Thanks again.....

Apr 20 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Donald Firesmith | last post: by
4 posts views Thread by Porthos | last post: by
23 posts views Thread by Mat | last post: by
9 posts views Thread by Patient Guy | last post: by
2 posts views Thread by Eric Lindsay | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.