XSL function 2 ---- Method of objects in the DOM

zhaozj2021-02-16  49

XSL function 2 ---- Method of objects in the DOM

This issue introduces multiple XSL for VBScript, JScript increases, attribute to give full play to the advantage of XML, useful in , Decoration or , , < XSL: WHEN> EXPR properties.

First, AbsolutechildNumber

Meaning: Return Node relative to all the brothers (regardless of the name of the name)

Syntax: AbsolutechildNumber (NODE)

Parameters: Node - object, want to return the node of the number.

Example:

1. Assume that the document structure is: , where Document is the top-level node, the following expression will output

AbsolutechildNumber (this.selectnodes ("/ document / body"). Item (0))

2, determine the current node relative to the serial number of all its brothers

AbsolutechildNumber (this)

Second, AncStorchildNumber

Meaning: From the given junction, the serial number of the nearest ancestral node is returned according to the given ancestor node name (relative to the same name node). Returns 0 if you find no ancestors.

Syntax: AncStorchildNumber (BSTRNODENAME, PNODE)

parameter:

BSTRNODENAME - String. The name of the ancestral node searched.

PNode - object. Search the node of the start position.

Example:

Find the current node recently named Report ancestor node.

AncStorchildNumber ("Report", this)

Third, Attributes

Meaning: Return to the collection of node properties

Object.attributes

Parameters: Object - Node Object

Example:

Number of current node properties

this.attributes.length

The value of the current node third attribute

this.attributs.Item (2) .value

Or this.attributes.Item (2) .text

Or this.attributes (2) .Text

Note: If a given subscript is greater than the total sum of the attribute, it will be reduced, the subscript of the first attribute is 0.

Fourth, BaseName

Meaning: Returns the basic name of the name spatial restriction, ie not including the name prefix

Grammar: Object.basename

Parameters: Object - Node Object

Example: Basic name for the current node: this.basename

V. ChildNumber

Meaning: Return to the serial number relative to the same class

Grammar: ChildNumber (Object)

Parameters: Object ─? 岬 韵? / P>

Example: Assume that the XML document structure is as follows

If the current node is Z, ChildNumber (this) returns 1, and AbsolutechildNumber (this) returns 3.

Sixth, Datatype

Meaning: Set or read the data type of node

Syntax: Setting Node Data Type Object.DataType = ObjValue Read Node ObjValue = Object.DataType

Parameters: Object - Node Object

Example: Read the data type of the current node

DTTYPE = this.DataType

Seven, depth

Meaning: The designated node appears in the depth of the document tree, that is, the node is located in the first few layers of the document, and the top layer is located

The first layer, the root node (ie the node expressed by "/") is located at 0

Syntax: DEPTH (PNODE)

Parameters: PNODE - Node Object

Example: the depth of the current node

DEPTH (this)

Eight, Firstchild, Lastchild

Meaning: Returns the first sub-node of the node (or the last sub-node).

Syntax: pnode.firstchild

Pnode.lastchild

Parameters: PNODE - Node Object

Example: The name of the first node of the current node

this.firstchild.nodeName

Nine, Formatindex

Meaning: Format the integer provided with the specified count system.

Syntax: Formatindex (Lindex, BStrFormat)

parameter:

LINDEX - integer value or variable

BStrformat - data format, optional value A, A, I, I, 1, 01 (with 0 header), if the number of fixed lengths is required, such as 0001,0002 is very useful)

Example: Current Number of Current Number Roman Digital Number

Formatindex (ChildNumber (this), "i")

Ten, FormatNumber

Meaning: The value is output in the specified format.

Grammar: FormatNumber (DBLNumber, BStrFormat)

Parameters: Description With FormatNumber, the difference is that the formatted can be a decimal

Example: Value formatted to the variable A is two decimal formatNumber (a, "#. 00")

11. HaschildNodes

Meaning: If the node has a sub-node, returns true (-1), otherwise false (0)

Syntax: pnode.haschildnodes ()

Note: Unlike the functions previously described, this function must have an empty bracket.

Example: Judging whether the current node has a sub-node

this.haschildnodes

Twelve, Namespaceuri, Prefix

Meaning: Returns the global resource identifier (or prefix) of node namespace

Syntax: pnode.namespaceuri

Pnode.prifix

Thirteen, nextsibling, previoussibling, ParentNode

Meaning: Return to the next brother (or the previous brother, or the father of the node)

Syntax: pnode.nextsibling

Pnode.previoussibling

pnode.parentnode

Note: Apply a ParentNode method for root nodes (ie, "/"), apply the previoussibling method for the first child node, apply the nextsibling method for the last child's node, can cause errors, which can pass this relationship operator == (Equal to) and! = (Not equal) to determine if a node is specified node, format is pnode1 = pnode2 or pnode2! = Pnode2. Fourteen, nodename

Meaning: Returns a specific string of elements, attributes, entrances, or other type of node

Syntax: pnode.nodeename

Example: the name of the current node

this.nodename

Fifteen, nodetype, nodetypeString

Meaning: Numerical form of the type of node (or string form)

Syntax: pnode.nodetype or pnode.nodetypeString

return value:

Node Type Node Type Node Node Type String Element 1 "Element" Element Properties 2 "Attribute" Markup-Delimited Region of Text 3 "Text" Processing Instruction 7 "Processing_instruction" Comment 8 "Comment" Document Entity 9 "Document"

XVI, NodeTypedValue

Meaning: Returns the value of node with a predefined data type of node

Syntax: pnode.nodetyped accuue

Example: Assume that the data type of the current node is fixed.14.4, the following example will return the value of the node with a value rather than the text

this.nodetypedValue

Seventeenth, NodeValue

Meaning: Back to the text

Grammar: pnode.nodevalue

Note: This method is not used for elemental sources, available for attributes, cdata, annotations, text and other nodes.

Example: Current value of the first attribute of the element

THIS.Attributes (0) .NodeValue

Text within the current element (assuming that only text in this element, no other elements, " text , it is recommended to give more exact usage several times)

this.firstchild.NodeValue

Eighteen, OwnerDocument

Meaning: Returns the root of the document containing the node

Syntax: pnode.ownerdocument

Note: This method is used for the root node of the document.

19, SelectNodes

Meaning: The given style matching is applied to the current node and returns a match collection.

Syntax: pnode.selectnodes ("pattern")

Tip: Pattern's writing and value type, which is expressed in "/"

Depart from the root of the document; "//" starts all the nodes of the document; ".."

Indicates that from the parent node of the current node; if you want to search from the current node, you can't have the above special characters.

Example: Number of elements with the same name with the current node in their parent elements

ChildNumber (this.selectnodes ("../" this.nodeename " [end ()] "). Item (0))

Number of elements of the current element name "skill"

ChildNumber ("Skill [end ()]"). Item (0)) 20, Selectsinglenode

Meaning: Similar to SelectNodes, different returns only the first node, not the gathering collection

Syntax: pnode.selectsinglenode ("pattern")

Example: Number of elements with the same name with the current node in their parent elements

ChildNumber (this.selectsinglenode ("./" this.nodeename " [end ()] "))

Number of elements of the current element name "skill"

ChildNumber (this.selectsinglenode ("Skill [end ()]"))

21, Text

Meaning: Return to the text content with its subtree

Syntax: pnode.text

Example: text content in the entire document

this.ownerDocument.text

Current element and its subtree text content

this.Text

Twenty-two, XML

Meaning: return node and its descendants XML

Syntax: pnode.xml

Example: the XML content of the current document

this.ownerDocument.xml

There are several functions that are not introduced, listed in response, if you are interested, please visit http://msdn.microsoft.com Get a detailed description.

FormatTime (Vartime, Bstrformat, VARDestLocale)

Formatdate (Vardate, BstrFormat, VARDestLocale)

Apendchild (Newchild)

Definition

Clonenode

INSERTBEFORE (Newchild, Refchild)

parse

RemoveChild (Oldchild)

Replacechild (NewChild, Oldchild)

Specified

TransformNode (Stylesheet)

TransformNodetoObject (Stylesheet, OutputObject)

UniqueID (PNODE)

转载请注明原文地址:https://www.9cbs.com/read-25847.html

New Post(0)