非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

An XSLTProcessor applies an XSLT stylesheet transformation to an XML document to produce a new XML document as output. It has methods to load the XSLT stylesheet, to manipulate <xsl:param> parameter values, and to apply the transformation to documents.

句法

The constructor has no parameters.

new XSLTProcessor()
					

方法

[Throws] void XSLTProcessor.importStylesheet ( 节点 styleSheet)
Imports the XSLT stylesheet. If the given node is a document node, you can pass in a full XSL Transform or a literal result element transform ; otherwise, it must be an <xsl:stylesheet> or <xsl:transform> 元素。
[Throws] DocumentFragment XSLTProcessor.transformToFragment ( 节点 source, Document owner)
Transforms the node source by applying the stylesheet imported using the XSLTProcessor.importStylesheet() function. The owner document of the resulting document fragment is the owner node.
[Throws] Document XSLTProcessor.transformToDocument ( 节点 source)

Transforms the node source applying the stylesheet given importing using the XSLTProcessor.importStylesheet() 函数。

The resultant object depends on the output method of the stylesheet:

Output method Result type
html HTMLDocument
xml XMLDocument
text XMLDocument with a single root element <transformiix:result> with the text as a child
[Throws] void XSLTProcessor.setParameter ( 字符串 namespaceURI, 字符串 localName, any value)
Sets a parameter in the XSLT stylesheet that was imported. (Sets the value of an <xsl:param> .) A null value for namespaceURI is treated the same as an empty string.
[Throws] any XSLTProcessor.getParameter ( 字符串 namespaceURI, 字符串 localName)
Gets the value of a parameter from the XSLT stylesheet. A null value for namespaceURI is treated the same as an empty string.
[Throws] void XSLTProcessor.removeParameter ( 字符串 namespaceURI, 字符串 localName)
Removes the parameter if it was previously set. This will make the XSLTProcessor use the default value for the parameter as specified in the stylesheet. A null value for namespaceURI is treated the same as an empty string.
void XSLTProcessor.clearParameters()
Removes all set parameters from the XSLTProcessor XSLTProcessor will then use the defaults specified in the XSLT stylesheet.
void XSLTProcessor.reset()
Removes all parameters and stylesheets from the XSLTProcessor .

特性

Non-Web-exposed properties

The following properties are [ChromeOnly] and not exposed to Web content:

[ChromeOnly] attribute unsigned long XSLTProcessor.flags

Flags that tweak the behavior of the processor. Not reset by calling XSLTProcessor.reset() . Default value: 0

Possible values are:

名称 Effect
(None) 0 None
DISABLE_ALL_LOADS 1 Disable loading external documents (via e.g. <xsl:import> and document() )

范例

  1. 基本范例
  2. Advanced example
  3. Additional example

规范

Not part of any specification. This is a proprietary interface that originated in Gecko.

Gecko IDL

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
XSLTProcessor 非标 Chrome Yes Edge ≤18 Firefox Yes IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
clearParameters 非标 Chrome Yes Edge 12 Firefox Yes IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
getParameter 非标 Chrome Yes
Yes
Chrome only supports string values.
Edge 12 Firefox Yes IE No Opera Yes
Yes
Opera only supports string values.
Safari Yes WebView Android Yes
Yes
Chrome only supports string values.
Chrome Android Yes
Yes
Chrome only supports string values.
Firefox Android Yes Opera Android Yes
Yes
Opera only supports string values.
Safari iOS Yes Samsung Internet Android Yes
Yes
Samsung Internet only supports string values.
importStylesheet 非标 Chrome Yes Edge 12 Firefox Yes IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
removeParameter 非标 Chrome Yes Edge 12 Firefox Yes IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
reset 非标 Chrome Yes Edge 12 Firefox Yes IE No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
setParameter 非标 Chrome Yes
Yes
Chrome only supports string values.
Edge 12 Firefox Yes IE No Opera Yes
Yes
Opera only supports string values.
Safari Yes WebView Android Yes
Yes
Chrome only supports string values.
Chrome Android Yes
Yes
Chrome only supports string values.
Firefox Android Yes Opera Android Yes
Yes
Opera only supports string values.
Safari iOS Yes Samsung Internet Android Yes
Yes
Samsung Internet only supports string values.
transformToDocument 非标 Chrome Yes
Yes
Chrome returns null if an error occurs.
Edge 12 Firefox Yes
Yes
Firefox throws an exception if an error occurs.
IE No Opera Yes
Yes
Opera returns null if an error occurs.
Safari Yes WebView Android Yes
Yes
Chrome returns null if an error occurs.
Chrome Android Yes
Yes
Chrome returns null if an error occurs.
Firefox Android Yes
Yes
Firefox throws an exception if an error occurs.
Opera Android Yes
Yes
Opera returns null if an error occurs.
Safari iOS Yes Samsung Internet Android Yes
Yes
Samsung Internet returns null if an error occurs.
transformToFragment 非标 Chrome Yes
Yes
Chrome returns null if an error occurs.
Edge 12 Firefox Yes
Yes
Firefox throws an exception if an error occurs.
IE No Opera Yes
Yes
Opera returns null if an error occurs.
Safari Yes WebView Android Yes
Yes
Chrome returns null if an error occurs.
Chrome Android Yes
Yes
Chrome returns null if an error occurs.
Firefox Android Yes
Yes
Firefox throws an exception if an error occurs.
Opera Android Yes
Yes
Opera returns null if an error occurs.
Safari iOS Yes Samsung Internet Android Yes
Yes
Samsung Internet returns null if an error occurs.

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. XSLTProcessor

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1