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

Name Type get set Descripton
autoNameMapping Boolean checked checked When 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.
rootNode Node checked checked The XML element that describes the root of the object hierarchy. Only set this before you actually use the parser.

Methods

Name Description
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.
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.
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.
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.

Events

None.

Static Methods

Name Description
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.
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.
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.

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
 )
 

Parameters

Name Type Optional Default Descripton
oNode Node The XML node to create an object for.

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

Name Type Optional Default Descripton
sId String The 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

Name Type Optional Default Descripton
o BiObject The object to map the attributes onto
oNode Node The 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

Name Type Optional Default Descripton
obj BiObject The object to map the children onto
oNode Node The 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

Name Type Optional Default Descripton
oDoc BiXmlDocument The 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

Name Type Optional Default Descripton
oNode Node The 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

Name Type Optional Default Descripton
oUri Biuri The 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