Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


How to display images when it is included in a text description

From: "klingus@-----.---" <-------@-----.--->
To: NULL
Date: 8/5/2007 1:34:00 AM

Hi,

I am in need of some xslt assistance.  My xslt isn't rendering the
<img> tag when it is copied to the html page.

As you can see from the pasted code, the xml has in the <description>
tag embedded <img> but when I run the xslt, I get the full text but
the image isn't rendered.

Thank you for any assistance.
Kelvin

Below is the code for a test page:

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>XML Transform : Firefox and IE</title>
	<style>
		body{
			font:75%/150% "Trebuchet MS", "Lucida Grande", "Bitstream Vera
Sans", Arial, Helvetica, sans-serif;
			color:#666666;
			margin:100px;
		}

		td, th{
			padding:5px;
		}

		th{
			background:#993333;
			color:#ffffff;
		}
	</style>

	<script>
		function runTransform(){
			if(document.implementation &&
document.implementation.createDocument){
				// Mozilla

				var xsltProcessor = new XSLTProcessor();

				// load the xslt file
				var myXMLHTTPRequest = new XMLHttpRequest();
				myXMLHTTPRequest.open("GET", "test.xsl", false);
				myXMLHTTPRequest.send(null);

				// get the XML document
				xslStylesheet = myXMLHTTPRequest.responseXML;
				xsltProcessor.importStylesheet(xslStylesheet);

				// load the xml file
				myXMLHTTPRequest = new XMLHttpRequest();
				myXMLHTTPRequest.open("GET", "test.xml", false);
				myXMLHTTPRequest.send(null);

				var xmlSource = myXMLHTTPRequest.responseXML;

				//transform
				 var resultDocument = xsltProcessor.transformToFragment(xmlSource,
document);
				document.getElementById("example").appendChild(resultDocument);

			}else if(window.ActiveXObject){
				// IE

				// Load XML
				xml = new ActiveXObject("MSXML2.DOMDocument");
				xml.async = false
				xml.load("test.xml")

				// Load XSL
				xsl = new ActiveXObject("MSXML2.DOMDocument");
				xsl.async = false
				xsl.load("test.xsl")


				// Transform
	
document.getElementById("example").innerHTML=xml.transformNode(xsl);
			}else{
				// Browser unknown
				alert("Browser unknown");
			}
		}
	</script>
</head>

<body onLoad="runTransform()">
<div id="example"></div>

</body>
</html>

XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
    <h2>U.S. News</h2>
    <table border="0">
    <tr>
      <th align="left">Title</th>
      <th align="left">Description</th>
    </tr>
    <xsl:for-each select="item">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:copy-of select="description"/></td>
    </tr>
    </xsl:for-each>
    </table>
</xsl:template>
</xsl:stylesheet>

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<item>
<title>Bridge search ends for day with no luck (AP)</title>
<description>&#60;p>&#60;a href="http://us.rd.yahoo.com/dailynews/rss/
us/*http://news.yahoo.com/s/ap/20070805/ap_on_re_us/
bridge_collapse">&#60;img src="http://d.yimg.com/us.yimg.com/p/ap/
20070804/
capt.b25df21cf4b0422e9074c64fac8e72e5.bush_bridge_collapse_wxs108.jpg?
x=130&amp;y=82&amp;sig=W0JdM0O4ep3mPDPq7pz2.w--" align="left"
height="82" width="130" alt="Divers continue the search for bodies
among the debris of the collapsed Interstate 35W bridge, just yards
away from where President Bush was meeting with public officials and
emergency crews in Minneapolis, Saturday, Aug. 4, 2007. The number of
dead stands at five, but authorities said another eight bodies likely
were trapped in the wreckage. (AP Photo/Joey McLeister, Pool)"
border="0" />&#60;/a>AP - Divers spent a third fruitless day searching
for victims of a deadly bridge collapse, finding no bodies inside a
crushed car pulled earlier Saturday from the murky Mississippi River
waters.&#60;/p>&#60;br clear="all"/></description>
</item>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent