xsl:template match="/"

2017-08-11  本文已影响0人  ccphantom

In XPath, there are seven kinds of nodes:
element, attribute, text, namespace, processing-instruction, comment, and document nodes
The value of the match attribute of the <xsl:template> instruction must be a match pattern.

Match patterns form a subset of the set of all possible XPath expressions. The first, natural, limitation is that a match pattern must select a set of nodes. There are also other limitations. In particular, reverse axes are not allowed in the location steps (but can be specified within the predicates). Also, no variable or parameter references are allowed in XSLT 1.0, but using these is legal in XSLT 2.x.

/ in XPath denotes the root or document node. In XPath 2.0 (and hence XSLT 2.x) this can also be written as document-node().

Examples of match patterns:

<xsl:template match="table">
can be applied on any element named table.

<xsl:template match="x/y">
can be applied on any element named y whose parent is an element named x.

<xsl:template match="*">
can be applied to any element.

<xsl:template match="/*">
can be applied only to the top element of an XML document.

<xsl:template match="@*">
can be applied to any attribute.

<xsl:template match="text()">
can be applied to any text node.

<xsl:template match="comment()">
can be applied to any comment node.

<xsl:template match="processing-instruction()">
can be applied to any processing instruction node.

<xsl:template match="node()">
can be applied to any node: element, text, comment or processing instructon.

上一篇下一篇

猜你喜欢

热点阅读