473,320 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can XSLT render the content: &lt;p&gt as html <p> rather than text?

I have an element, report which contains tags which have been
transformed. E.g. <pis &lt;p&gt

<myXml>
<report>This text has html tags in it.&lt;p&gt which but <has been
changed to &lt;&gt</report>
</myXml>

I there a way that the XSLT transformation can render the content as
html rather than text?

PS: I tried to cludge this by getting the xmlDOM, then using javascript
to get the the <reporttext but this just gives inconsistent results
(sometimes the <reportdisplays and other times I get an error telling
me that the expected item is null.

var reportTxt = getNodeText(oXmlDom.getElementsByTagName('report') );

a watch on oXmlDom.getElementsByTagName('report') shows the item is
there.

a watch on reportTxt shows no item (= null).

It's not the getNodeText() because when I do:

var reportNode = oXmlDom.getElementsByTagName('report');

I get the same, a watch on oXmlDom.getElementsByTagName('report') shows
the node is there; a watch on reportNode shows no node present.

This is just a crazy error which I can't debug.

On balance, I prefer the XSLT transform if possible.
Mar 13 '08 #1
4 11866
mark4asp wrote:
I have an element, report which contains tags which have been
transformed. E.g. <pis &lt;p&gt

<myXml>
<report>This text has html tags in it.&lt;p&gt which but <has been
changed to &lt;&gt</report>
</myXml>

I there a way that the XSLT transformation can render the content as
html rather than text?
Well the proper way to solve that is at the source, instead of escaping
the HTML markup you should insert well-formed XHTML markup, then your
XSLT stylesheet can easily copy it to the output or transform it to HTML
if needed.
If you can't do that then one approach is disable-output-escaping e.g.
<xsl:template match="report">
<div>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
However disable-output-escaping is an optional feature that is not
supported by all XSLT processors respectively is not supported with all
XSLT uses (for instance when chaining XSLT tranformations). So you will
have to check whether it works with your XSLT processor in the setting
you use it with.

Other than that you are left with processing and parsing the text with
the escaped markup and create elements as needed, a task that is rather
difficult with the restricted string processing that XSLT/XPath 1.0 offer.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 13 '08 #2
Martin Honnen wrote:
<xsl:template match="report">
<div>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
Thanks again. This is working in IE6 on my PC, so I hope it continues
to work with the other browsers; now that the trickiest one is OK.

However. I guess it depends on what the client has installed... It will
be a bit hit and miss.
Mar 13 '08 #3
mark4asp wrote:
Martin Honnen wrote:
> <xsl:template match="report">
<div>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>

Thanks again. This is working in IE6 on my PC, so I hope it continues
to work with the other browsers; now that the trickiest one is OK.
No, if you rely on the browser to perform the XSLT transformation then
you should not rely on disable-output-escaping. Firefox for instance
does not support it at all
<URL:http://developer.mozilla.org/en/docs/XSL_Transformations_in_Mozilla_FAQ#Can_I_do_disabl e-output-escaping.3F>
as it does not serialize the transformation result.
If you want to rely on disable-output-escaping then perform the XSLT
transformation on the server where you control the XSLT processor.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 13 '08 #4
Martin Honnen wrote:
mark4asp wrote:
Martin Honnen wrote:
<xsl:template match="report">
<div>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
Thanks again. This is working in IE6 on my PC, so I hope it
continues to work with the other browsers; now that the trickiest
one is OK.

No, if you rely on the browser to perform the XSLT transformation
then you should not rely on disable-output-escaping. Firefox for
instance does not support it at all <url:
http://developer.mozilla.org/en/docs..._in_Mozilla_FA
Q#Can_I_do_disable-output-escaping.3Fas it does not serialize the
transformation result. If you want to rely on
disable-output-escaping then perform the XSLT transformation on the
server where you control the XSLT processor.
Point taken, but the page is working OK with IE 6 sp2 and IE7. I am
only required to get this website working with those browsers. It
doesn't work with FF, Opera or Safari. I'll change it to a server XSLT
when I have time, as I try to follow some kind of standard though my
boss just hates the mention of the word.

Mar 13 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
12
by: Sammy | last post by:
Hi, my mind is going crazy. I have tried everything I can think of to no avail. I have tried Disable Output Escaping. I tried to think of a way of enclosing the attribute data in a CDATA...
2
by: Francesco Moi | last post by:
Hello. I designed a form to edit some DataBase's fields. But some of these fields contain '&lt;' and '&gt;' characters. And these characters are '<' and '>' in HTML. So if want to edit these...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
2
by: Jasonkimberson | last post by:
I am doing a data pull of HTML from a database that will be put into a drop down menu currently after i pull and populate the information, it converts my < into &lt; whats the work around for...
2
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node...
4
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt;...
1
by: Robert Dodier | last post by:
Hello, Sorry for asking what must be a FAQ, but I wasn't able to find the answer. I have an XML document fragment which I want to store as a text string. I want a function to convert any XML...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.