This content has been marked as final. Show 4 replies
xmlFile = air.File.applicationDirectory;
xmlFile = xmlFile.resolvePath(filename);
stream = new air.FileStream();
xmlDoc = stream.readUTFBytes(stream.bytesAvailable);
var domParser = new DOMParser();
xmlDoc = domParser.parseFromString(xmlDoc, "text/xml");
resultDocument = xsltProcessor.transformToFragment(xml,document);
<body id="example" onLoad="displayResult()">
(replace books.xml and books.xsl with your own files, obviously.)
For reference, here is my XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">
<h2>Fairly Odd Books </h2>
<li><em><xsl:value-of select="title"/></em> by <xsl:value-of select="author"/></li>
And the XML file:
<?xml version="1.0" encoding="utf-8" ?>
<title>The Flying Circus</title>
Thanks for your answer.
Looking at the Wekbit API I came to the same conclusion. I was also trying to use Document.load method, but it seems that Webkit is the only engine that does not implement it yet.
Hum... I've another problem now. I need to do some regexp transformation from the xml content.
I've tried to use the exslt regexp extension, but it is not present in webkit, and add the script in the xsl doesn't help neither (the function is not found by the xslt processor).
So, I tryed to define a "replace" function in the sandbox and place some <script>replace(...)</script> in the xsl. The problem is that the <script> tag are well translated by the xslt processor, but not interpretate when appending the fragment to the document. Is there a way to tell to indicate to webkit that he should also execute the content of the script tag?