BiXmlResourceParser

This class deserializes an XML document to a Bindows object hierarchy. This is mostly tailored for BiComponent hierarchies but can be used for any class extending BiObject.

This class extends BiXmlLoader and therefore all methods and fields available for BiXmlLoader are also available for BiXmlResourceParser .

Constructor

new BiXmlResourceParser ( )

Parameters

No parameters.

Properties

NameTypegetsetDescripton
autoNameMappingBooleancheckedcheckedWhen this is true any XML object that has an id attribute will create a global reference (with the same name as the id value) to the object created from this XML element.
rootNodeNodecheckedcheckedThe XML element that describes the root of the object hierarchy. Only set this before you actually use the parser.

Methods

NameDescription
fromNodeTakes an XML element and returns a BiObject (or a derivative). The tag name is used as the class name and for each attribute, setAttribute is called on the object. For each child node (unless it declares a complex property) addXmlNode is called on the object.
getComponentByIdReturns the component (BiObject) with the given id property. If the parser has not yet encountered an element with this id attribute it will look forward in the document and if an element is found with the given id it will be deserialized and the object will be returned.
processAttributesThis takes an object and an XML element and then goes through the attributes and calls setAttribute on the object.

This is also where attached properties are handled. See the remarks.
processChildNodesThis takes an object and an XML element and then goes through all the child nodes of the XML element and calls addXmlNode on the object.

This is also where complex properties are handled. See the remarks.

Events

None.

Static Methods

NameDescription
getClassFromDocumentCreates a constructor that uses the XML document as its base. This constructor can then be used to create instances of this class or used to create sub classes.
getClassFromNodeCreates a constructor that uses the XML element as its base. This constructor can then be used to create instances of this class or used to create sub classes.
getClassFromUriLoads an XML document from the URI and then creates a constructor that can then be used to create instances of that class. See the remarks below.

Static Fields

None.

Remarks

When creating a class from a node or URI the class will extend the class that the root element is of. The class will have a property getter called xmlResourceParser that returns the resource loader and a method called getComponentById that allows lookup of objects from the XML resource. Classes created in this way will call a method called initialize from the constructor using the same arguments that were passed to the constructor Complex properties are represented using child elements with a tag name matching the class name of the current element followed by a '.' and then the property name. <Component> <Component.border> <Border color="red"/> </Component.border> </Component> Attached properties are a special kind of properties that follow an interface with the following format: ClassName.setProperty(oSource, sValue) This is represented using the following XML code: <Component ClassName.property="value"/>

Method Details

fromNode

Takes an XML element and returns a BiObject (or a derivative). The tag name is used as the class name and for each attribute, setAttribute is called on the object. For each child node (unless it declares a complex property) addXmlNode is called on the object.

Syntax

object.fromNode ( oNode,oParent )

Parameters

NameTypeOptionalDefaultDescripton
oNodeNodeThe XML node to create an object for.
oParentObjectThe object that will be the parent of the object created from this node.

Return Type

Object

getComponentById

Returns the component (BiObject) with the given id property. If the parser has not yet encountered an element with this id attribute it will look forward in the document and if an element is found with the given id it will be deserialized and the object will be returned.

Syntax

object.getComponentById ( sId )

Parameters

NameTypeOptionalDefaultDescripton
sIdStringThe id of the object to find

Return Type

BiObject

processAttributes

This takes an object and an XML element and then goes through the attributes and calls setAttribute on the object.

This is also where attached properties are handled. See the remarks.

Syntax

object.processAttributes ( o,oNode )

Parameters

NameTypeOptionalDefaultDescripton
oBiObjectThe object to map the attributes onto
oNodeNodeThe XML element that provides the attributes

Return Type

void

processChildNodes

This takes an object and an XML element and then goes through all the child nodes of the XML element and calls addXmlNode on the object.

This is also where complex properties are handled. See the remarks.

Syntax

object.processChildNodes ( obj,oNode )

Parameters

NameTypeOptionalDefaultDescripton
objBiObjectThe object to map the children onto
oNodeNodeThe XML element that provides the child nodes

Return Type

void

Static Method Details

getClassFromDocument

Creates a constructor that uses the XML document as its base. This constructor can then be used to create instances of this class or used to create sub classes.

Syntax

BiXmlResourceParser . getClassFromDocument ( oDoc )

Parameters

NameTypeOptionalDefaultDescripton
oDocBiXmlDocumentThe XML document used to describe the object hierarchy.

Return Type

Function

getClassFromNode

Creates a constructor that uses the XML element as its base. This constructor can then be used to create instances of this class or used to create sub classes.

Syntax

BiXmlResourceParser . getClassFromNode ( oNode )

Parameters

NameTypeOptionalDefaultDescripton
oNodeNodeThe XML node used to describe the object hierarchy.

Return Type

Function

getClassFromUri

Loads an XML document from the URI and then creates a constructor that can then be used to create instances of that class. See the remarks below.

Syntax

BiXmlResourceParser . getClassFromUri ( oUri )

Parameters

NameTypeOptionalDefaultDescripton
oUriBiuriThe location of the file. If this is a string a new URI is created from that string relative to the ADF path.

Return Type

Function