Xinf API Reference
Back | Index
class xinf.xml.XMLElement
extends Node
implements EventDispatcher
implements TraitAccess

An Element, like a tag in an XML document, but also the base class for all Xinfony Elements.

Element provides the basics to implement TraitAccess and EventDispatcher.

var base :String [StringTrait]

The current base URL/URI/IRI for this element. Can be set to specify a different base URL, possibly relative to an "inherited" base.

See also: xml:base

var id :String [StringTrait]

Standard XML unique name ("id" attribute).

As there is no namespace support at the moment, this recognized both "id" and "xml:id", with (not-standard-conformantly) the later attribute taking precedence.

FIXME: should update the document's index when changed.

See also: xml:id

var name :String [StringTrait]
textual name of the Element ("name" attribute)
function new( ?traits:Dynamic ) :Void

Create a new, empty Element.

If traits is given, it will be set using setTraitsFromObject.

function getTrait<T>( name:String, type:Dynamic ) :T
see TraitAccess.getTrait
function setTrait<T>( name:String, value:T ) :T
see TraitAccess.setTrait()
function setStyleTrait<T>( name:String, value:T ) :T

see TraitAccess.setStyleTrait()

On xinf.xml.XMLElement, there is no difference between get/setStyleTrait and get/setTrait, but StyledElement makes the difference.

function getStyleTrait<T>( name:String, value:T, ?inherit:Bool ) :T
see TraitAccess.getStyleTrait()
function setTraitFromString( name:String, value:String, to:Dynamic ) :Void
see TraitAccess.setTraitFromString()
function setTraitFromDynamic( name:String, value:Dynamic, to:Dynamic ) :Void
see TraitAccess.setTraitFromDynamic()
function setTraitsFromObject( o:Dynamic ) :Void
Set the traits of this Element from the dynamic object o. Uses StyleParser.fromObject(), so the field values of o can be of any type that can be converted by the respective TraitDefinition. Usually, this includes String and the native type of the Trait.
function setTraitsFromXml( xml:Xml ) :Void

Set the traits of this object from the given Xml's attribute values.

Namespaces are currently ignored. Internally, this uses XMLElement.setTraitFromString().

function addEventListener<T>( type:EventKind<T>, h:T -> Void ) :T -> Void
see EventDispatcher.addEventListener()
function removeEventListener<T>( type:EventKind<T>, h:T -> Void ) :Bool
see EventDispatcher.removeEventListener()
function removeAllListeners<T>( type:EventKind<T> ) :Bool
Convenience function to remove all listeners of the given type.
function dispatchEvent<T>( e:Event<T> ) :Void

see EventDispatcher.dispatchEvent()

Do not use this function directly, instead use postEvent().

function postEvent<T>( e:Event<T>, ?pos:PosInfos ) :Void
see EventDispatcher.postEvent()
Back | Index