Analytics XSL (5)-methods and attributes added to VBScript and JScript by multiple XSL

Source: Internet
Author: User
Tags processing instruction xsl
This section describes the methods and attributes added by multiple XSL for VBScript and JScript to give full play to the advantages of XML, which are used for <XSL: SCRIPT>, <XSL: eval> compile the expression within the tag or the expr attribute of <XSL: If> and <XSL: When>.

 

1. absolutechildnumber

Meaning: return the sequence number of the node relative to all its brothers (regardless of whether the name is the same.

Syntax: absolutechildnumber (node)

Parameter: node-object. The node number to be returned.

Example:

1. Assume that the document structure is <document>

<XSL: eval>
Absolutechildnumber (this. selectnodes ('/document/body'). Item (0 ))
</XSL: eval>

2. determine the sequence number of the current node relative to all its brothers:

<XSL: eval>
Absolutechildnumber (this)
</XSL: eval>

2. ancestorchildnumber

Meaning: return the sequence number of the nearest ancestor Node Based on the given ancestor node name (relative to the Same Name node ). If no ancestor is found, 0 is returned.

Syntax: ancestorchildnumber (bstrnodename, pnode)

Parameters:

Bstrnodename ── string. Name of the searched ancestor node.

Pnode-object. Search for the Start Node.

In the example, find the closest report ancestor node to the current node:

Ancestorchildnumber ('report', this)

Iii. Attributes

Meaning: return the set of node attributes.

Syntax: object. Attributes

Parameter: Object-Node object.

Example: Number of current node attributes

This. Attributes. Length

Value of the third attribute 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 greater than the sum of attributes minus 1, an error occurs. The subscript of the first attribute is 0.

Iv. basename

Meaning: returns the basic name with a namespace restriction, that is, the name prefix is not included.

Syntax: object. basename

Parameter: Object-Node object

For example, the basic name of the current node:

This. basename

V. childnumber

Meaning: return the sequence number of the node relative to the same name compatriot.

Syntax: childnumber (object)

Parameter: Object-Node object

For example, assume that the XML document structure is as follows:

<X> <Y> <z> </Y> </x>

If the current node is Z, childnumber (this) returns 1, while absolutechildnumber (this) returns 3.

6. datatype

Description: sets or reads the Data Type of a node.

Syntax: Set the Data Type of the Node object. datatype = objvalue
Data Type of the read node objvalue = object. datatype

Parameter: Object-Node object.

For example, read the data type of the current node:

Dttype = This. datatype

VII. Depth

Meaning: Specify the depth of the node that appears on the document tree, that is, the node at the document layer, the top node at the first layer, and the root node (that is, the node represented) located at Layer 0th.

Syntax: depth (pnode)

Parameter: pnode-Node object

For example, the depth of the current node:

Depth (this)

8. firstchild and lastchild

Meaning: return the first subnode (or the last subnode) of the node ).

Syntax: pnode. firstchild
Pnode. lastchild

Parameter: pnode-Node object

For example, the name of the first node of the current node:

This. firstchild. nodename

9. formatindex

Meaning: format the provided integer with the specified counting system.

Syntax: formatindex (lindex, bstrformat)

Parameters:

Lindex ── integer value or variable

Bstrformat-data format. Optional values include a, a, I, I, 1, and 01 (in the form of a value with 0 headers, it is useful if Fixed Length numbers such as 0001 and 0002 are required ).

For example, the upper-case roman numerals of the current node:

Formatindex (childnumber (this), 'I ')

10. formatnumber

Meaning: outputs a value in a specified format.

Syntax: formatnumber (dblnumber, bstrformat)

Parameter: The description is the same as formatnumber. The difference is that the format can be decimal.

For example, the value of variable A is formatted as two decimal places:

Formatnumber (A, '#. 00 '):

11. haschildnodes

Meaning: If a node has a subnode, true (-1) is returned; otherwise, false (0) is returned ).

Syntax: pnode. haschildnodes ()

Note: Unlike the previously described function, this function must contain an empty parenthesis.

Example to determine whether the current node has a subnode:

This. haschildnodes

12. namespaceuri and prefix

Meaning: return the Global Resource Identifier (or prefix) of the node namespace ).

Syntax: pnode. namespaceuri
Pnode. prifix

13. nextsibling, previussibling, and parentnode

Meaning: return the next brother of the node (or the parent node of the previous brother or node ).

Syntax: pnode. nextsibling
Pnode. previussibling
Pnode. parentnode

Note: An error occurs when you apply the parentnode Method to the root node (that is, "/"), apply the previoussibling Method to the first child node, and apply the nextsibling Method to the last child node, you can use this relational operator = (equal to) and! = (Not equal to) to determine whether a node is a specified node, in the format of pnode1 = pnode2 or pnode2! = Pnode2.

14. nodename

Meaning: return an element, attribute, entry name, or a specific string of another type node.

Syntax: pnode. nodename

For example, the name of the current node:

This. nodename

15th, nodetype, nodetypestring

Meaning: return the numeric form (or string form) of the node type ).

Syntax: pnode. nodetype or pnode. nodetypestring

Return Value:

Node Type Node Type Value Character Form description of a node
Element 1 'Element'
Element attribute 2 'Attribute'
Markup-delimited region of Text 3 'Text'
Processing Instruction 7 'Processing_instruction'
Comment 8 'Comment'
Document entity 9 'Document'

Sixteen, nodetypedvalue

Meaning: return the value of a node based on the predefined Data Type of the node.

Syntax: pnode. nodetypedvalue

For example, assume that the data type of the current node is fixed.14.4. In the following example, the value of the node is returned as a numerical value instead of a text string:

This. nodetypedvalue

17. nodevalue

Meaning: return the text of the node.

Syntax: pnode. nodevalue

Note: This method is not used for element nodes. It can be used for attributes, CDATA, comments, text, and other nodes.

For example, the value of the first attribute of the current element:

This. attributes (0). nodevalue

Text in the current element (assuming that the element contains only text, no other elements, that is, <mark> text </mark>, we recommend that you try it several times to learn its exact usage ).

This. firstchild. nodevalue

18. ownerdocument

Meaning: return the root of the document containing the node.

Syntax: pnode. ownerdocument

Note: This method is used for root-point errors in the document.

Nineteen, selectnodes

Meaning: The given style match is applied to the current node and the matched node set is returned.

Syntax: pnode. selectnodes ('pattern ')

Tip: The pattern compilation is similar to the value of the select attribute of <XSL: For-each>, where "/" indicates searching from the root of the document; start with "//" and traverse all nodes of the document. Start ".. "starts with the parent node of the current node. If you want to search down from the current node, you cannot start with the above special characters.

For example, the number of elements with the same name as the current node in its parent element:

Childnumber (this. selectnodes ("../" + this. nodename + "[end ()]"). Item (0 ))

The number of "skill" elements in the current element:

Childnumber (this. selectnodes ("skill [end ()]"). Item (0 ))

20. selectsinglenode

Meaning: similar to selectnodes, only the matching first node instead of the node set is returned.

Syntax: pnode. selectsinglenode ('pattern ')

For example, the number of elements with the same name as the current node in its parent element:

Childnumber (this. selectsinglenode ("../" + this. nodename + "[end ()]")

The number of "skill" elements in the current element:

Childnumber (this. selectsinglenode ("skill [end ()]")

21. Text

Meaning: return the node and the text content in its subtree.

Syntax: pnode. Text

For example, the text content in the entire document:

This. ownerdocument. Text

Text Content of the current Element and Its subtree:

This. Text

22. xml

Meaning: return the XML Representation of the node and its descendants.

Syntax: pnode. xml

For example, the XML content of the current document:

This. ownerdocument. xml

Several other functions are not introduced and listed below for reference. If you are interested, please visit the http://msdn.microsoft.com for detailed instructions.

formattime (vartime, bstrformat, vardestlocale)
formatdate (vardate, bstrformat, vardestlocale)
apendchild (newchild)
definition
clonenode
insertbefore (newchild, refchild)
parsed
removechild (oldchild)
replaceChild (newchild, oldchild)
specified
transformnode (stylesheet)
transformnodetoobject (stylesheet, outputobject)
uniqueid (pnode)

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.