|
Yate
|
Xml Element. More...
#include <yatexml.h>
Public Member Functions | |
| XmlElement (const NamedList &element, bool empty, XmlParent *parent=0) | |
| XmlElement (const char *name, bool complete=true) | |
| XmlElement (const XmlElement &orig) | |
| virtual | ~XmlElement () |
| const char * | tag () const |
| bool | isDefaultNs () const |
| const String & | unprefixedTag () const |
| const String & | getTag () const |
| bool | getTag (const String *&tag, const String *&ns) const |
| virtual XmlElement * | xmlElement () |
| virtual XmlElement * | element () |
| virtual XmlSaxParser::Error | addChild (XmlChild *child) |
| virtual XmlChild * | removeChild (XmlChild *child, bool delObj=true) |
| virtual void | setCompleted () |
| bool | completed () const |
| bool | empty () const |
| XmlElement * | parent () const |
| virtual XmlParent * | getParent () |
| virtual void | setParent (XmlParent *parent) |
| virtual const String & | getName () const |
| virtual const NamedList & | getElement () const |
| const ObjList & | getChildren () const |
| void | clearChildren () |
| const NamedList * | inheritedNs () const |
| void | setInheritedNs (const XmlElement *xml=0, bool inherit=true) |
| void | addInheritedNs (const NamedList &list) |
| XmlElement * | pop () |
| virtual const String & | toString () const |
| void | toString (String &dump, bool escape=true, const String &indent=String::empty(), const String &origIndent=String::empty(), bool completeOnly=true, const String *auth=0) const |
| XmlElement * | findFirstChild (const String *name=0, const String *ns=0, bool noPrefix=true) const |
| XmlElement * | findNextChild (XmlElement *prev=0, const String *name=0, const String *ns=0, bool noPrefix=true) const |
| const String & | getText () |
| void | addText (const char *text) |
| const NamedList & | attributes () const |
| unsigned int | copyAttributes (NamedList &list, const String &prefix) const |
| void | setAttribute (const String &name, const char *value) |
| void | setAttributeValid (const String &name, const char *value) |
| const char * | attribute (const String &name) const |
| String * | getAttribute (const String &name) const |
| bool | hasAttribute (const String &name, const String &value) const |
| void | removeAttribute (const String &name) |
| String * | xmlns () const |
| String * | xmlnsAttribute (const String &name) const |
| bool | hasXmlns (const String &ns) const |
| bool | setXmlns (const String &name=String::empty(), bool addAttr=false, const String &value=String::empty()) |
Static Public Member Functions | |
| static bool | isXmlns (const String &str) |
| static XmlElement * | param2xml (NamedString *param, const String &tag, bool copyXml=false) |
| static NamedString * | xml2param (XmlElement *xml, const String *tag, bool copyXml=false) |
| static void | xml2param (NamedList &list, XmlElement *parent, const String *tag, bool copyXml=false) |
Static Public Attributes | |
| static const String | s_ns |
| static const String | s_nsPrefix |
Xml Element.
Xml Element from a Xml document
| XmlElement | ( | const NamedList & | element, |
| bool | empty, | ||
| XmlParent * | parent = 0 |
||
| ) |
Constructor
| element | The NamedList name represent the element name and the param the attributes |
| empty | False if has children |
| parent | The parent of this element |
| XmlElement | ( | const char * | name, |
| bool | complete = true |
||
| ) |
Constructor. Creates a new complete and empty element
| name | The name of the element |
| complete | False to build an incomplete element |
| XmlElement | ( | const XmlElement & | orig | ) |
Copy constructor
| orig | Original XmlElement |
| virtual ~XmlElement | ( | ) | [virtual] |
Destructor
Append a new child of this element
| child | The child to append |
Implements XmlParent.
Referenced by XMPPUtils::createFailure(), XMPPUtils::createIqAuthGet(), XMPPUtils::createIqResult(), XMPPUtils::createXOobUrl(), and XMPPUtils::setPriority().
| void addInheritedNs | ( | const NamedList & | list | ) |
Add inherited namespaces from a list
| list | The list of namespaces |
| void addText | ( | const char * | text | ) |
Obtain an attribute value for the given name
| name | The name of the attribute |
| const NamedList& attributes | ( | ) | const [inline] |
Retrieve the list of attributes
| void clearChildren | ( | ) | [inline, virtual] |
Helper method to clear the children list
Reimplemented from XmlParent.
| bool completed | ( | ) | const [inline] |
Referenced by XmlElement::pop().
| unsigned int copyAttributes | ( | NamedList & | list, |
| const String & | prefix | ||
| ) | const |
Copy element attributes to a list of parameters
| list | Destination list |
| prefix | Prefix to be added to each attribute name |
| virtual XmlElement* element | ( | ) | [inline, virtual] |
Get an XmlElement from this XmlParent
Reimplemented from XmlParent.
Referenced by XmlElement::parent().
| bool empty | ( | ) | const [inline] |
| XmlElement* findFirstChild | ( | const String * | name = 0, |
| const String * | ns = 0, |
||
| bool | noPrefix = true |
||
| ) | const [inline] |
Find the first child of this XmlElement
| name | Optional name of the child |
| ns | Optional child namespace |
| noPrefix | True to compare the tag without namespace prefix, false to include namespace prefix when comparing the given tag. This parameter is ignored if name is 0 or ns is not 0 |
References XmlFragment::findElement().
| XmlElement* findNextChild | ( | XmlElement * | prev = 0, |
| const String * | name = 0, |
||
| const String * | ns = 0, |
||
| bool | noPrefix = true |
||
| ) | const [inline] |
Finds next child of this XmlElement
| prev | Previous child |
| name | Optional name of the child |
| ns | Optional child namespace |
| noPrefix | True to compare the tag without namespace prefix, false to include namespace prefix when comparing the given tag. This parameter is ignored if name is 0 or ns is not 0 |
References ObjList::find(), XmlFragment::findElement(), and ObjList::skipNext().
| String* getAttribute | ( | const String & | name | ) | const [inline] |
Obtain an attribute value for the given name
| name | The name of the attribute |
Referenced by XMPPUtils::isResponse().
| const ObjList& getChildren | ( | ) | const [inline, virtual] |
| virtual const NamedList& getElement | ( | ) | const [inline, virtual] |
Retrieve the element's tag (without prefix)
Referenced by XMPPUtils::getTag(), and XMPPUtils::tag().
Retrieve the element's tag (without prefix) and namespace
| tag | Pointer to element tag |
| ns | Pointer to element's namespace (may be 0 for unprefixed tags) |
Referenced by XMPPUtils::subject().
| bool hasAttribute | ( | const String & | name, |
| const String & | value | ||
| ) | const [inline] |
Check if the element has an attribute with a requested value
| name | The name of the attribute |
| value | The value to check |
Verify if this element belongs to the given namespace
| ns | The namespace to compare with |
Referenced by XMPPUtils::hasXmlns().
| const NamedList* inheritedNs | ( | ) | const [inline] |
Retrieve the list of inherited namespaces
| bool isDefaultNs | ( | ) | const [inline] |
Check if this element must be processed in the default namespace (its tag is not prefixed)
Check if a string represents a namespace attribute name
| str | The string to check |
References String::startsWith().
| static XmlElement* param2xml | ( | NamedString * | param, |
| const String & | tag, | ||
| bool | copyXml = false |
||
| ) | [static] |
Build an XML element from a list parameter. Parameter name will be set in a 'name' attribute. Parameter value will be set in a 'value' attribute Handle NamedPointer parameters carrying DataBlock, NamedList and XmlElement objects (a 'type' attribute is added to the created element). DataBlock: Encode using BASE64 and add it as element text NamedList: The name is added as element text. The function is called again for each list parameter XmlElement: Added as child to newly created element
| param | The parameter to convert |
| tag | XmlElement tag |
| copyXml | True to copy XmlElement objects instead of just remove them from the parameter |
| XmlElement* parent | ( | ) | const [inline] |
Retrieve an XmlElement parent of this one
References XmlElement::element().
| XmlElement* pop | ( | ) | [inline] |
| void removeAttribute | ( | const String & | name | ) | [inline] |
Remove an attribute
| name | Attribute name |
| virtual XmlChild* removeChild | ( | XmlChild * | child, |
| bool | delObj = true |
||
| ) | [virtual] |
| void setAttribute | ( | const String & | name, |
| const char * | value | ||
| ) | [inline] |
Add or replace an attribute
| name | Attribute name |
| value | Attribute value |
| void setAttributeValid | ( | const String & | name, |
| const char * | value | ||
| ) | [inline] |
Add or replace an attribute. Clears it if value is empty
| name | Attribute name |
| value | Attribute value |
References TelEngine::null().
Referenced by XMPPUtils::createParameter().
| virtual void setCompleted | ( | ) | [inline, virtual] |
Notification for this element that is complete
| void setInheritedNs | ( | const XmlElement * | xml = 0, |
| bool | inherit = true |
||
| ) |
Set inherited namespaces from a given element. Reset them anyway
| xml | The source element used to set inherited namespaces |
| inherit | Copy element's inherited namespaces if it doesn't have a parent |
Set this element's parent. Update inherited namespaces
Reimplemented from XmlChild.
| bool setXmlns | ( | const String & | name = String::empty(), |
| bool | addAttr = false, |
||
| const String & | value = String::empty() |
||
| ) |
Set the element's namespace
| name | The namespace name (element prefix). Can be the default namespace attribute name (empty means the default one) |
| addAttr | True to add a non empty, not repeating, namespace attribute to the list |
| value | Namespace value (ignored if addAttr is false) |
Referenced by XMPPUtils::createElement(), and XMPPUtils::setXmlns().
| const char* tag | ( | ) | const [inline] |
Retrieve the element's tag
| void toString | ( | String & | dump, |
| bool | escape = true, |
||
| const String & | indent = String::empty(), |
||
| const String & | origIndent = String::empty(), |
||
| bool | completeOnly = true, |
||
| const String * | auth = 0 |
||
| ) | const |
Build (append to) a String from this XmlElement
| dump | The destination string |
| escape | True if the attributes values need to be escaped |
| indent | Spaces for output |
| origIndent | Original indent |
| completeOnly | True to build only if complete |
| auth | Optional list of tag and attribute names to be replaced with '***'. This parameter can be used when the result will be printed to output to avoid printing authentication data to output. The array must end with an empty string |
| const String& unprefixedTag | ( | ) | const [inline] |
Retrieve the element's tag unprefixed (namespace prefix removed)
Referenced by XMPPUtils::isUnprefTag().
| static NamedString* xml2param | ( | XmlElement * | xml, |
| const String * | tag, | ||
| bool | copyXml = false |
||
| ) | [static] |
Build a list parameter from xml element See param2xml for more info
| xml | The XML element to process |
| tag | Child XmlElement tag to handle |
| copyXml | True to copy XmlElement objects instead of just remove them from parent |
| static void xml2param | ( | NamedList & | list, |
| XmlElement * | parent, | ||
| const String * | tag, | ||
| bool | copyXml = false |
||
| ) | [static] |
Build and add list parameters from XML element children. Each parameter will be taken from 'name' and 'value' attributes. See param2xml for more info
| list | Destination list |
| parent | The XML element to process |
| tag | Child XmlElement tag to handle |
| copyXml | True to copy XmlElement objects instead of just remove them from parent |
| virtual XmlElement* xmlElement | ( | ) | [inline, virtual] |
Retrieve the element's namespace
Referenced by XMPPUtils::ns(), and XMPPUtils::xmlns().
| String* xmlnsAttribute | ( | const String & | name | ) | const |
Retrieve a namespace attribute. Search in parent or inherited for it
Referenced by XMPPUtils::hasDefaultXmlns().
Default namespace attribute name
Referenced by XMPPUtils::hasDefaultXmlns().
const String s_nsPrefix [static] |
Namespace attribute name perfix
1.7.6.1