Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: How to display images when it is included in a text description How to display images when it is included in a text descriptionTo: 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><p><a href="http://us.rd.yahoo.com/dailynews/rss/ us/*http://news.yahoo.com/s/ap/20070805/ap_on_re_us/ bridge_collapse"><img src="http://d.yimg.com/us.yimg.com/p/ap/ 20070804/ capt.b25df21cf4b0422e9074c64fac8e72e5.bush_bridge_collapse_wxs108.jpg? x=130&y=82&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" /></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.</p><br clear="all"/></description> </item> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
