[webkit-dev] JavaScript for XML with XSL

Pierre Bernard i_love_my at mac.com
Sun Feb 17 13:51:33 PST 2008


Hi Mark, Eric and all,

the following works:

<html>
<head>
<script>
function displayResult()
{
var xmlRequest = new XMLHttpRequest();
xmlRequest.open("GET", "cdcatalog.xml", false);
xmlRequest.send(null);
xml= xmlRequest.responseXML;

var xslRequest = new XMLHttpRequest();
xslRequest.open("GET","cdcatalog.xsl", false);
xslRequest.send(null);
xsl = xslRequest.responseXML;

  xsltProcessor=new XSLTProcessor();
  xsltProcessor.importStylesheet(xsl);
  resultDocument = xsltProcessor.transformToFragment(xml,document);
  document.getElementById("example").appendChild(resultDocument);
}
</script>
</head>
<body onload="displayResult()">
<div id="example" />
</body>
</html>

Best,
Pierre


On 17 Feb 2008, at 16:29, Mark Rowe wrote:

> Pierre,
>
> On 18/02/2008, at 02:10, Pierre Bernard wrote:
>
>> function loadXMLDoc(fname)
>> {
>> var xmlDoc;
>> xmlDoc=document.implementation.createDocument("","",null);
>>
>> xmlDoc.async=false;
>> xmlDoc.load(fname);
>> return(xmlDoc);
>> }
>
>
> The code fails with the following error:
>
> Value undefined (result of expression xmlDoc.load) is not object.
> http://www.w3schools.com/xsl/tryit_view.asp?filename=cdcatalog (line  
> 22)
>
> The Document.load method being called here appears to be part of the  
> June 2003 working draft of DOM Level 3 Load and Save Specification (http://www.w3.org/TR/2003/WD-DOM-Level-3-LS-20030619/ 
> ), but has since been removed from that specification.  Firefox,  
> Opera and Internet Explorer appear to implement this method in some  
> form.  WebKit's lack of support for this method is tracked by <http://bugs.webkit.org/show_bug.cgi?id=9063 
> >.
>
> If you change your code to load the XML document via a method that  
> WebKit does support do you have better luck with processing it via  
> XSL?
>
> - Mark
>

---
Pierre Bernard
http://www.bernard-web.com/pierre
http://www.houdah.com



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
Url : http://lists.webkit.org/pipermail/webkit-dev/attachments/20080217/5bf5c071/attachment.bin 


More information about the webkit-dev mailing list