Result of Transforming XML by XSLT in Different Browsers
2008-07-04 21:31
302 查看
Generally most of the browsers transform XMLs in 2 ways, I mean two kinds of APIs
For IE serial browsers, we got
It's pretty easy, but the disadvantage is that the result is pure text.
Another way is supported by Mozilla, Opera, and Safari serial browsers
It returns a document as result, that's better than IE. The problem for these browsers is, the transform result from XSLT is expected to be ONE element. Which means the following kind of result is incorrect.
Because they are 2 elements.
In this situation, Firefox handle it in the way that wrap the result with a <transformiix:result /> tag. Whild Safari will show an error message (TOO bad).
To solve the problem, wrap the result with another tag like
Or another way
For detail information of these APIs, go to the following link:
http://developer.mozilla.org/cn/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations
Although non-IE serial browsers returns DOM element for us, we can not take the advantage of it because of cross-browser issues. Instead, we have to serialize the element into a string, and then we can deal with it in the same way as IE.
(Tested in IE6, FF2, Safari3)
For IE serial browsers, we got
xml.transformNode(xsl) |
Another way is supported by Mozilla, Opera, and Safari serial browsers
var processor = new XSLTProcessor(); processor.importStylesheet(xsl); var result = processor.transformToDocument(xml); |
<div>...</div><div>...</div> |
In this situation, Firefox handle it in the way that wrap the result with a <transformiix:result /> tag. Whild Safari will show an error message (TOO bad).
To solve the problem, wrap the result with another tag like
<div> <div>...</div> <div>...</div> </div> |
var result =processor.transformToFragment(xml, xml); |
http://developer.mozilla.org/cn/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations
Although non-IE serial browsers returns DOM element for us, we can not take the advantage of it because of cross-browser issues. Instead, we have to serialize the element into a string, and then we can deal with it in the same way as IE.
var xmls = new XMLSerializer(); var html = xmls.serializeToString(result); |
相关文章推荐
- Result of Transforming XML by XSLT in Different Browsers
- What are the different kinds of parsers used in XML?
- Transforming XML Data with XSLT in .NET [1/3]
- What is the maximum length of a URL in different browsers?
- Simple sample for transforming XML to HTML by using XSLT
- Transforming XML Data with XSLT in .NET [2/3]
- Transforming XML Data with XSLT in .NET [3/3]
- Deprecated: Assigning the return value of new by reference is deprecated in……【解决方法】
- Report on Environmental Monitoring in the College Archives and Sophia Smith Collection Conducted by the Massachusetts Board of Library Commissioners, August 2001-Janaury 2002
- (NOT CLEAR)Question 45: Which of the following options are returned by the typeid operator in C++?
- "Exception: org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find result map...
- [转]how to programatically access built-in properties of open xml word doc(如何读取open xml格式文档属性)
- How do I sort an array of hashes by a value in the hash?
- mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg
- 论文阅读:Segmentation of teeth in CT volumetric dataset by panoramic projection and variational level se
- improving performance of your web page by use gzip in you web server.
- mysql 1130错误 和1055 - Expression #1 of ORDER BY clause is not in GROUP BY
- \t\tINFO: Performance of XSLT Transformations in the .NET Framework
- Deprecated: Assigning the return value of new by reference is deprecated in……【解决方法】
- Embedding Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office