Introduction to XSL Functions (1)

Source: Internet
Author: User

This issue introduces multiple XSL methods and attributes for VBScript, JScript, to give full play to the XML advantages for < Xsl:script >, < xsl:eval > Markup Expression Authoring or < Xsl:if >, < xsl:when > Expr attribute.

First, Absolutechildnumber

Meaning: Returns the ordinal number of a node relative to all its siblings (regardless of the name)

Syntax: Absolutechildnumber (node)

Parameters: node── object, to return the number of nodes.

Example:

1. Assume that the document structure is:< documents >< head/>< body/></document, where documentation is the top-level node and the following expression outputs

< Xsl:eval >

Absolutechildnumber (This.selectnodes ("/document/body"). Item (0))

</xsl:eval >

2. Determine the serial number of the current node relative to all of its brothers

< Xsl:eval >absolutechildnumber (this) </xsl:eval >

Second, Ancestorchildnumber

Meaning: Returns the ordinal number of the nearest ancestor node (relative to the same node) based on the given ancestor node name, starting at the given node. Returns 0 if the ancestor is not found.

Syntax: Ancestorchildnumber (Bstrnodename, Pnode)

Parameters:

bstrnodename── string. The name of the ancestor node being searched.

pnode── object. The node where the search starts.

Example:

Finds the nearest name of the current node, called the statement ancestor node.

Ancestorchildnumber ("The", this)

Third, attributes

Meaning: Returns a collection of node attributes

Syntax: object.attributes

Parameters: object── Node Object

Example:

Number of current node properties

This.attributes.length

The value of the third property of the current node

This.attributs.item (2). value

or This.attributes.item (2). Text

or This.attributes (2). Text

Note: If the given subscript is larger than the property sum minus 1, the subscript for the first property is 0.

Four, BaseName

Meaning: Returns the base name with a namespace limit, that is, not including the name prefix

Syntax: Object.basename

Parameters: object── Node Object

Example: the base name of the current node: this.basename

Five, Childnumber

Meaning: Returns the ordinal number of a node relative to a sibling of the same name

Syntax: Childnumber (object)

Parameter: object─? Cape Leng Yun?/p>

Example: Assuming that the XML document is structured as follows

< x >< y >< z >< z/>< y/></x >

If the current node is Z, Childnumber (this) returns 1, and Absolutechildnumber (this) returns 3.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.