While working on the Crash Statistics website, I came to the following situation.
I have a Django installation running in the form of our crash statistics website, it provides dynamic webpages and one of the crash logs uploaded by users of my application (other information ), These logs are in XML and are roughly made in this way:
& lt ;? Xml ...? & Gt; & Lt ;? Xml-stylesheet type = "text / xsl" ...? & Gt; ... & lt; Runtylag & gt; & Lt; Xsl: stylesheet id = "stylesheet" version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" & gt; & Lt; Xsl: template match = "xsl: stylesheet" /> & Lt; Xsl: template match = "/ runtylag" & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Style type = "text / css" & gt; ... some styling codes ... & lt; / Style & gt; & Lt; Script language = "javascript" & gt; ... some mobility code ... & lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; ... Some HTML, XSL, and JS ... for page layout ... / Body & gt; & Lt; / Html & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt; & Lt; LogHeader & gt; ... & lt; / LogHeader & gt; & Lt; LogEvents & gt; ... & lt; / LogEvents & gt; & Lt; / RunTimeLog & gt;
Now, as you can see, a file contains everything necessary to render a log file (because we want the log to be easily distributed and readable) . This code works as magic, while opening XML in the browser, a well-formatted log appears. Now I am trying to present it in a separate page using the following DNS templates:
< Pre> & lt; Html & gt; & Lt; Top & gt; ... Import JQuery and other awesome stuff ... & lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "log" & gt; & Lt; / Div & gt; & Lt; Div id = "log buffer" & gt; {{Log}} & lt ;! - DJJanga includes raw XML here ... - & gt; & Lt; / Div & gt; & Lt; Script & gt; XSLT processor = new XSLTProcessor (); ResultDocument = xsltProcessor.transformToFragment ($ ('#logbuffer'). InnerHTML, document); $ ('Logon') attached (resultDocument). & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Now, it is not working ... Logbuffer DP displays raw XML as expected, but the formatting does not work and gives the second line in the script Null to result document .
I think the weather is this right approach? Does anyone know why this is not working? I know there are several ways to solve this problem by way of the Django and, but I want to keep the formatting client side.
Any help would be appreciated!
{{log}}
escaped html is inserted, not raw. Then $ ('# logbuffer'). InnerHTML
returns
& amp; Lt ;? Xml ...? & Gt; & Amp; Lt ;? Xml-stylesheet type = & amp; Quot; Text / xsl & amp; Quot; ...? & Amp; Gt; And so on ...
You must mark the log
variable as secure:
{{log | Safe}}
No comments:
Post a Comment