OverviewSingleDeprecated

jsx3.xml

class Entity

Object
->jsx3.lang.Object
  ->jsx3.xml.Entity

Direct Known Subclasses:

jsx3.xml.Document

class Entity
extends jsx3.lang.Object
Wrapper of the native browser XML node class. This class provides methods for querying, traversing, and creating XML entities.

This class is never instantiated by the developer, rather instances are returned from various methods in this class and the jsx3.xml.Document class.

Note that several methods of this class fail quietly when an error occurs with the wrapped native browser XML classes. Methods that are documented as failing quietly should always be followed by a call to hasError() to ensure that no error has occurred.

Field Summary
static int
TYPEATTRIBUTE
The node type for an attribute node.
static int
TYPECDATA
The node type for a character data node.
static int
TYPECOMMENT
The node type for a comment node.
static int
TYPEELEMENT
The node type for an element node.
static int
TYPETEXT
The node type for a text node.
Constructor Summary
void
init(objEntity : Object)
The instance initializer.
Method Summary
jsx3.xml.Entity
Appends the objEntity parameter as a child of this entity.
jsx3.xml.Entity
cloneNode(bDeep : boolean)
Creates a new node that is an exact clone of this node.
jsx3.xml.Entity
createNode(intType : int, strNodeName : String, strNS : String)
Creates a new node and returns as jsx3.xml.Entity instance
boolean
equals(objEntity : jsx3.xml.Entity)
Tests the equivalency of two jsx3.xml.Entity instances as they wrap and can therefore point to the same native entity, causing a standard "==" comparison to fail
String
getAttribute(strName : String)
Returns the value for the named attribute strName.
Array<String>
Returns the names of all the attributes of this node.
jsx3.xml.Entity
Returns an object reference (a jsx3.xml.Entity instance) to the child attribute with the name, @strName.
jsx3.util.List<jsx3.xml.Entity>
Returns handle to a jsx3.util.List instance of all children; note that this collection will always be empty (length = 0) for all types except for jsx3.xml.Entity.TYPEELEMENT
String
Returns the right-hand side of a namespace qualified name.
jsx3.util.Iterator<jsx3.xml.Entity>
getChildIterator(bIncludeText : boolean)
Returns an iterator that iterates over the child nodes of this node.
jsx3.util.List<jsx3.xml.Entity>
getChildNodes(bIncludeText : boolean)
Returns the child nodes of this entity.
Object
Returns an error object (a plain JavaScript object) with two properties that the developer can query for: code – an integer error code, 0 for no error.
jsx3.xml.Entity
Returns the first child element of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if both conditions are not met
jsx3.xml.Entity
Returns the last child element of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if both conditions are not met
String
Returns the value (as string) for URI (universal resource identifier) of the namespace for the given node; returns an empty string if no namespace exists
Object
Returns the native browser XML node wrapped by this entity.
jsx3.xml.Entity
Returns the next sibling if this node and the referenced sibling are of type jsx3.xml.Entity.TYPEELEMENT; returns null if condition is not met
String
Returns the name of the node as string (assuming this jsx3.xml.Entity instance is of type jsx3.xml.Entity.TYPEELEMENT or jsx3.xml.Entity.TYPEATTRIBUTE).
int
Returns one of: jsx3.xml.Entity.TYPEELEMENT, jsx3.xml.Entity.TYPEATTRIBUTE, jsx3.xml.Entity.TYPETEXT, jsx3.xml.Entity.TYPECDATA
jsx3.xml.Document
Returns the document that owns this entity.
jsx3.xml.Entity
Returns the parent node as a jsx3.xml.Entity instance; if this node is the root node of the document, null is returned
String
Returns the left-hand side of a namespace qualified name.
jsx3.xml.Entity
Returns the previous sibling if this node and the referenced sibling are of type jsx3.xml.Entity.TYPEELEMENT; returns null if condition is not met
jsx3.xml.Entity
Returns reference to the document element (root) wrapped in jsx3.xml.Entity instance
String
Contains the text content of the node, including the concatenated text contained by all descendant entities
static String
Deprecated.
String
Deprecated. Use toString() instead.
boolean
Returns true if the last operation on this XML entity caused an error.
jsx3.xml.Entity
insertBefore(objEntityNew : jsx3.xml.Entity, objEntityRef : jsx3.xml.Entity)
inserts the jsx3.xml.Entity instance, @objEntityNew immediately before the existing child @objEntityRef and returns a handle to @objEntityNew; requires that both parameters be of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if all conditions are not met
void
removeAttribute(strAttName : String)
Removes the specified attribute by the given name (can only be called for nodes of type jsx3.xml.Entity.TYPELEMENT)
jsx3.xml.Entity
removes the attribute object as a child of the element;
jsx3.xml.Entity
removeChild(objChildEntity : jsx3.xml.Entity)
Removes the specified child (@objChildEntity) from the list of children and returns it; returns null if @objChildEntity is not actually a child
void
Removes all descendant entities of this node
jsx3.xml.Entity
replaceNode(objEntityNew : jsx3.xml.Entity, objEntityOld : jsx3.xml.Entity)
replaces the child @objEntityOld with @objEntityNew and returns a handle to @objEntityOld; requires that both child entities be of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if all conditions are not met
jsx3.util.Iterator<jsx3.xml.Entity>
selectNodeIterator(strQuery : String, strNS : String | Object)
Returns an iterator that iterates over the the result of an XPath query.
jsx3.util.List<jsx3.xml.Entity>
selectNodes(strQuery : String, strNS : String | Object)
Returns a list of nodes selected by an XPath query executed on this node.
jsx3.xml.Entity
selectSingleNode(strQuery : String, strNS : String | Object)
Returns a single node selected by an XPath query executed on this node, or null if none is selected.
jsx3.xml.Entity
setAttribute(strName : String, strValue : String)
Sets the @strValue of the named @strAttribute and binds as child of this
jsx3.xml.Entity
Sets the attribute object as a child of the element; if transferring an attribute from one element to another, this call must be preceded with removeAttributeNode on the previous owner
jsx3.xml.Entity
setValue(strValue : String)
sets the text value for this entity; returns a handle to this jsx3.xml.Entity instance
String
Returns the XML (as String) for this node and any descendants.
String | jsx3.xml.Document
transformNode(objEntityFilter : jsx3.xml.Entity, objParams : Object<String, String>, bObject : boolean)
performs an XSLT transformation, using @objEntityFilter as the XSLT filter for the transformation; returns results of the transformation as a string (of text/html/xml/etc)
Methods Inherited From jsx3.lang.Object
clone, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf
Field Detail

TYPEATTRIBUTE

static final int TYPEATTRIBUTE
The node type for an attribute node.

TYPECDATA

static final int TYPECDATA
The node type for a character data node.

TYPECOMMENT

static final int TYPECOMMENT
The node type for a comment node.

TYPEELEMENT

static final int TYPEELEMENT
The node type for an element node.

TYPETEXT

static final int TYPETEXT
The node type for a text node.
Constructor Detail

init

void init(objEntity : Object)
The instance initializer. If an error occurs while instantiating this entity, this method sets the error property of this entity and returns quietly.

Parameters:

objEntitythe browser native entity instance to wrap.
Method Detail

appendChild

jsx3.xml.Entity appendChild(objEntity : jsx3.xml.Entity)
Appends the objEntity parameter as a child of this entity. If an error occurs while appending to this XML entity, this method sets the error property of this entity and returns quietly.

Parameters:

objEntityjsx3.xml.Entity instance that will be bound as a child to this jsx3.xml.Entity instance

Returns:

reference to self  

cloneNode

jsx3.xml.Entity cloneNode(bDeep : boolean)
Creates a new node that is an exact clone of this node. If an error occurs while cloning this XML entity, this method sets the error property of this entity and returns quietly.

Parameters:

bDeepif true, all descendants of this object will also be cloned and returned

Returns:

newly cloned MSXML Node object wrapped in a jsx3.xml.Entity instance  

createNode

jsx3.xml.Entity createNode(intType : int, strNodeName : String, strNS : String)
Creates a new node and returns as jsx3.xml.Entity instance

Parameters:

intTypeFour types are supported: jsx3.xml.Entity.TYPEELEMENT, jsx3.xml.Entity.TYPEATTRIBUTE, jsx3.xml.Entity.TYPETEXT, jsx3.xml.Entity.TYPECDATA. Note: only nodes of TYPEELEMENT and TYPEATTRIBUTE will pay attention to the @strNodeName property; if not of this TYPE, pass an empty string
strNodeNamenode name for the node to add as a child
strNSnamespace URI for the node being created, if it is preceded by a URI. So, for example, if 'strName' is "xsi:string", then the 'strNS' value should be the namespace associated with the xsi prefix

Returns:

reference to the new node wrapped in a jsx3.xml.Entity instance  

equals

boolean equals(objEntity : jsx3.xml.Entity)
Tests the equivalency of two jsx3.xml.Entity instances as they wrap and can therefore point to the same native entity, causing a standard "==" comparison to fail

Parameters:

objEntityjsx3.xml.Entity object

Returns:

true or false  

Overrides:

equals in jsx3.lang.Object

getAttribute

String getAttribute(strName : String)
Returns the value for the named attribute strName.

Parameters:

strNamethe name of the attribute.

Returns:

the attribute value or undefined if the attribute does not exist.  

getAttributeNames

Array<String> getAttributeNames()
Returns the names of all the attributes of this node. Iterating over the attribute names is more performant than using the getAttributes() method.

Returns:

 

Since:

3.4

See Also:

getAttributes()

getAttributeNode

jsx3.xml.Entity getAttributeNode(strName : String)
Returns an object reference (a jsx3.xml.Entity instance) to the child attribute with the name, @strName. This method should only be called on an instance of type TYPEELEMENT.

Parameters:

strNamename of the attribute

Returns:

jsx3.xml.Entity instance referencing a single attribute node object  

getAttributes

jsx3.util.List<jsx3.xml.Entity> getAttributes()
Returns handle to a jsx3.util.List instance of all children; note that this collection will always be empty (length = 0) for all types except for jsx3.xml.Entity.TYPEELEMENT

Returns:

 

See Also:

getAttributeNames()

getBaseName

String getBaseName()
Returns the right-hand side of a namespace qualified name. For example, "Price" will be returned for the element <USD:Price>

Returns:

 

getChildIterator

jsx3.util.Iterator<jsx3.xml.Entity> getChildIterator(bIncludeText : boolean)
Returns an iterator that iterates over the child nodes of this node. Note that the iterator grants access to only one child node at a time; once next() is called, the value returned by the previous call to next() is no longer valid. This method is more performant than getChildNodes().

Parameters:

bIncludeTextif true then the returned iterator will include the child text nodes of this node.

Returns:

 

Since:

3.4

See Also:

getChildNodes()

getChildNodes

jsx3.util.List<jsx3.xml.Entity> getChildNodes(bIncludeText : boolean)
Returns the child nodes of this entity. By default this method only returns the child nodes that are elements. Text and CDATA children will be returned if bIncludeText is true.

Parameters:

bIncludeTextif true, text and cdata children are returned with element children.

Returns:

 

See Also:

getChildIterator()

getError

Object getError()
Returns an error object (a plain JavaScript object) with two properties that the developer can query for:

Returns:

 

getFirstChild

jsx3.xml.Entity getFirstChild()
Returns the first child element of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if both conditions are not met

Returns:

jsx3.xml.Entity instance or null  

getLastChild

jsx3.xml.Entity getLastChild()
Returns the last child element of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if both conditions are not met

Returns:

jsx3.xml.Entity instance or null  

getNamespaceURI

String getNamespaceURI()
Returns the value (as string) for URI (universal resource identifier) of the namespace for the given node; returns an empty string if no namespace exists

Returns:

 

getNative

Object getNative()
Returns the native browser XML node wrapped by this entity.

Returns:

 

getNextSibling

jsx3.xml.Entity getNextSibling()
Returns the next sibling if this node and the referenced sibling are of type jsx3.xml.Entity.TYPEELEMENT; returns null if condition is not met

Returns:

jsx3.xml.Entity instance or null  

getNodeName

String getNodeName()
Returns the name of the node as string (assuming this jsx3.xml.Entity instance is of type jsx3.xml.Entity.TYPEELEMENT or jsx3.xml.Entity.TYPEATTRIBUTE). The other TYPES return "#cdata-section" and "#text" respectively

Returns:

 

getNodeType

int getNodeType()
Returns one of: jsx3.xml.Entity.TYPEELEMENT, jsx3.xml.Entity.TYPEATTRIBUTE, jsx3.xml.Entity.TYPETEXT, jsx3.xml.Entity.TYPECDATA

Returns:

 

getOwnerDocument

jsx3.xml.Document getOwnerDocument()
Returns the document that owns this entity.

Returns:

 

getParent

jsx3.xml.Entity getParent()
Returns the parent node as a jsx3.xml.Entity instance; if this node is the root node of the document, null is returned

Returns:

parent node or null  

getPrefix

String getPrefix()
Returns the left-hand side of a namespace qualified name. For example, "USD" will be returned for the element <USD:Price>

Returns:

 

getPreviousSibling

jsx3.xml.Entity getPreviousSibling()
Returns the previous sibling if this node and the referenced sibling are of type jsx3.xml.Entity.TYPEELEMENT; returns null if condition is not met

Returns:

jsx3.xml.Entity instance or null  

getRootNode

jsx3.xml.Entity getRootNode()
Returns reference to the document element (root) wrapped in jsx3.xml.Entity instance

Returns:

jsx3.xml.Entity instance  

getValue

String getValue()
Contains the text content of the node, including the concatenated text contained by all descendant entities

Returns:

 

getVersion

static String getVersion()
Deprecated.
Returns the release/build for the class (i.e., "2.2.00")

Returns:

 

getXML

String getXML()
Deprecated. Use toString() instead.
Returns the XML (as String) for this node and any descendants. For an attribute this would be the attribute name and value (i.e., name="value")

Returns:

 

See Also:

toString()

hasError

boolean hasError()
Returns true if the last operation on this XML entity caused an error.

Returns:

 

insertBefore

jsx3.xml.Entity insertBefore(objEntityNew : jsx3.xml.Entity, objEntityRef : jsx3.xml.Entity)
inserts the jsx3.xml.Entity instance, @objEntityNew immediately before the existing child @objEntityRef and returns a handle to @objEntityNew; requires that both parameters be of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if all conditions are not met

Parameters:

objEntityNewjsx3.xml.Entity object (the new one to add)
objEntityRefjsx3.xml.Entity object (the reference node in front of which to insert the new node)

Returns:

jsx3.xml.Entity instance or null  

removeAttribute

void removeAttribute(strAttName : String)
Removes the specified attribute by the given name (can only be called for nodes of type jsx3.xml.Entity.TYPELEMENT)

Parameters:

strAttNamethe name of the attribute to remove

removeAttributeNode

jsx3.xml.Entity removeAttributeNode(objAtt : jsx3.xml.Entity)
removes the attribute object as a child of the element;

Parameters:

objAttjsx3.xml.Entity instance of type jsx3.xml.Entity.TYPEATTRIBUTE;

Returns:

reference to this  

removeChild

jsx3.xml.Entity removeChild(objChildEntity : jsx3.xml.Entity)
Removes the specified child (@objChildEntity) from the list of children and returns it; returns null if @objChildEntity is not actually a child

Parameters:

objChildEntityjsx3.xml.Entity object that is a direct child of this jsx3.xml.Entity instance

Returns:

jsx3.xml.Entity instance or null  

removeChildren

void removeChildren()
Removes all descendant entities of this node

replaceNode

jsx3.xml.Entity replaceNode(objEntityNew : jsx3.xml.Entity, objEntityOld : jsx3.xml.Entity)
replaces the child @objEntityOld with @objEntityNew and returns a handle to @objEntityOld; requires that both child entities be of type jsx3.xml.Entity.TYPEELEMENT; requires that this object also be of TYPEELEMENT; returns null if all conditions are not met

Parameters:

objEntityNewjsx3.xml.Entity object (the new one to add)
objEntityOldjsx3.xml.Entity object (the old one to remove)

Returns:

jsx3.xml.Entity instance or null  

selectNodeIterator

jsx3.util.Iterator<jsx3.xml.Entity> selectNodeIterator(strQuery : String, strNS : String | Object)
Returns an iterator that iterates over the the result of an XPath query. Note that the iterator grants access to only one child node at a time; once next() is called, the value returned by the previous call to next() is no longer valid. This method is more performant than selectNodes().

Parameters:

strQueryan XPath query such as: //somenode[@id='12']/somechild.
strNSthe selection namespace to use just for this query. This parameter is an optional shortcut for calling setSelectionNamespaces() on the owning document. The format of this parameter as a string is "xmlns:ns1='uri1' xmlns:ns2='uri2'" or as an object is {'uri1':'ns1', 'uri2':'ns2'}.

Returns:

 

Since:

3.4

See Also:

selectNodes()

selectNodes

jsx3.util.List<jsx3.xml.Entity> selectNodes(strQuery : String, strNS : String | Object)
Returns a list of nodes selected by an XPath query executed on this node.

Parameters:

strQueryan XPath query such as: //somenode[@id='12']/somechild.
strNSthe selection namespace to use just for this query. This parameter is an optional shortcut for calling setSelectionNamespaces() on the owning document. The format of this parameter as a string is "xmlns:ns1='uri1' xmlns:ns2='uri2'" or as an object is {'uri1':'ns1', 'uri2':'ns2'}.

Returns:

 

See Also:

selectNodeIterator()

selectSingleNode

jsx3.xml.Entity selectSingleNode(strQuery : String, strNS : String | Object)
Returns a single node selected by an XPath query executed on this node, or null if none is selected.

Parameters:

strQueryan XPath query such as: //somenode[@id='12']/somechild.
strNSthe selection namespace to use just for this query. This parameter is an optional shortcut for calling setSelectionNamespaces() on the owning document. The format of this parameter as a string is "xmlns:ns1='uri1' xmlns:ns2='uri2'" or as an object is {'uri1':'ns1', 'uri2':'ns2'}.

Returns:

jsx3.xml.Entity instance or null  

setAttribute

jsx3.xml.Entity setAttribute(strName : String, strValue : String)
Sets the @strValue of the named @strAttribute and binds as child of this

Parameters:

strNamename of the attribute
strValuevalue of the attribute, if null then remove the attribute

Returns:

reference to this  

setAttributeNode

jsx3.xml.Entity setAttributeNode(objAtt : jsx3.xml.Entity)
Sets the attribute object as a child of the element; if transferring an attribute from one element to another, this call must be preceded with removeAttributeNode on the previous owner

Parameters:

objAttjsx3.xml.Entity instance of type jsx3.xml.Entity.TYPEATTRIBUTE;

Returns:

reference to this  

setValue

jsx3.xml.Entity setValue(strValue : String)
sets the text value for this entity; returns a handle to this jsx3.xml.Entity instance

Parameters:

strValuevalue to set for this entity

Returns:

self  

toString

String toString()
Returns the XML (as String) for this node and any descendants. For an attribute this would be the attribute name and value (i.e., name="value")

Returns:

 

Overrides:

toString in jsx3.lang.Object

transformNode

String | jsx3.xml.Document transformNode(objEntityFilter : jsx3.xml.Entity, objParams : Object<String, String>, bObject : boolean)
performs an XSLT transformation, using @objEntityFilter as the XSLT filter for the transformation; returns results of the transformation as a string (of text/html/xml/etc)

Parameters:

objEntityFilterjsx3.xml.Entity instance containing the XSLT document to transform 'this' jsx3.xml.Entity instance with
objParamsJavaScript object array of name/value pairs; if passed, the transformation will use a paramaterized stylesheet to perform the transformation
bObjectif true this method returns a document instead of a string.

Returns:

the result of the transformation  

Returns:

jsx3.xml.Entity instance or null  

setAttribute

jsx3.xml.Entity setAttribute(strName : String, strValue : String)
Sets the @strValue of the named @strAttribute and binds as child of this

Parameters:

strNamename of the attribute
strValuevalue of the attribute, if null then remove the attribute

Returns:

reference to this  

setAttributeNode

jsx3.xml.Entity setAttributeNode(objAtt : jsx3.xml.Entity)
Sets the attribute object as a child of the element; if transferring an attribute from one element to another, this call must be preceded with removeAttributeNode on the previous owner

Parameters:

objAttjsx3.xml.Entity instance of type jsx3.xml.Entity.TYPEATTRIBUTE;

Returns:

reference to this  

setValue

jsx3.xml.Entity setValue(strValue : String)
sets the text value for this entity; returns a handle to this jsx3.xml.Entity instance

Parameters:

strValuevalue to set for this entity

Returns:

self  

toString

String toString()
Returns the XML (as String) for this node and any descendants. For an attribute this would be the attribute name and value (i.e., name="value")

Returns:

 

Overrides:

toString in jsx3.lang.Object

transformNode

String | jsx3.xml.Document transformNode(objEntityFilter : jsx3.xml.Entity, objParams : Object<String, String>, bObject : boolean)
performs an XSLT transformation, using @objEntityFilter as the XSLT filter for the transformation; returns results of the transformation as a string (of text/html/xml/etc)

Parameters:

objEntityFilterjsx3.xml.Entity instance containing the XSLT document to transform 'this' jsx3.xml.Entity instance with
objParamsJavaScript object array of name/value pairs; if passed, the transformation will use a paramaterized stylesheet to perform the transformation
bObjectif true this method returns a document instead of a string.

Returns:

the result of the transformation