开发者

No XSLTProcessor() support in Safari?

For whatever reason, I can't get XSLTProcessor() to work all the time.

Here is my JS:

... xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xmlRequest.responseXML);
// Pass variables
xsltProcessor.setParameter(null, "sectionNumber", section);
xsltProcessor.setParameter(null, "entryNumber", elementNo);

// Transform XML using XSL
var resultDocument = xsltProcessor.transformToFragment(phonebookDump,document);
/开发者_如何学JAVA/ Append to document
document.getElementById('three').appendChild(resultDocument);

Works fine in: Firefox on OSX, iPhone Simulator on OSX, Safari on OSX

Doesn't work at all in: Mobile Safari on iPhone, Safari on Windows

Am I missing something? Is there a workaround to XSLTProcessor()? Would server-side XSLT processing be quicker for mobile development anyways?


Your JS code seems right. Safari (and safari mobile as well) acutally has the xslt support. It's just a merciless implementation. The problem is that sometimes it may look like it is not working just because it is not verbose at all when it fails.

Remember that webkit xsl engine is based on libxsl, so you can use any software based on this library to test your style sheet against your document. I personally use xslproc that fails just like safari, but gives much more output.

If you can't get out of the problem, just post the xslt and the XML files.


I'm pretty sure Mobile Safari doesn't support XSLT, as the underlying OS X implementation does not include the relevant libraries that are present in desktop versions of OS X.

Server-side processing would definitely be quicker for a mobile app anyway: any processing you can reasonably shift away from the phone to the server is a win.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜