what :
Home > Objects > S > sadam.rapidXML > author : Adam Siska

sadam.rapidXML

A RapidXML wrapper for Max.


sadam.rapidXML will create, read, store or even modify DOM trees. The DOM is one of the possible representations of the contents of an XML document (see http://www.w3.org/TR/DOM-Level-2-Core/.) The object internally uses the RapidXML 1.13 library (see http://rapidxml.sourceforge.net/,) which is one of the fastest, yet still almost completely W3C compliant, freely available XML parsers.

When an XML is parsed, the object will assign a unique ID to each Element of the document, called the Element Index. This index won't get stored and changes each time when the order of Elements in the XML is modified (either by inserting or removing Elements). However, using the Element Index is the preferred (and in most cases, the only) way to address a given element in the XML. The Element Index is sent out the rightmost outlet each time an element is accessed. The Element Index of the Document Element is always 0, the rest of the Elements get their index in their 'order of appearence'. This means that even if an Element is being inserted or removed, the Index of the Elements that come earlier in the Document won't change.

When querying Attributes, Text, or CDATA nodes, the requested data will be sent out the appropriate outlets in right-to-left order (in case of Attributes, if more than one Attribute is requested, they will be sent to the output as a sequence like AttributeName1-AttributeValue1-AttributeName2-AttributeValue2-...-AttributeNameN-AttributeValueN, alternating on the appropriate outlets) followed by an error code. When querying Elements, the result will be sent out as a sequence (from right to left) consisting of the Element Index, the Tree Depth of the Element (the Document Element is at level 0, its children are at level 1 etc.), the Element's Tag Name, the Attributes, and finally the Text Content (which is a concatenation of all Text and CDATA nodes).

The leftmost outlet serves as an error outlet. After each command sent to the object, an error code is being sent back through this outlet at the end of the execution of the given command. A negative value means that the command could not be executed successfully, while 0 means success. In some cases (typically when one or more Elements are queried) the error outlet reports the number of Elements successfully returned.

As already mentioned, RapidXML 1.13 (and therefore sadam.rapidXML) is not fully W3C compliant. The main reason is that the parser ignores DOCTYPE declarations. There are also some difficulties with namespace management as well, the parser wouldn't refuse XMLs containing more than one root element and it will allow duplicate attributes for the same element. Also, to make parsing faster, all kind of XML validation is turned off by the wrapper Max object. If you need a 100% W3C compliant XML parser, consider sadam.dom, which is almost identical in functionality to sadam.rapidXML and requires MXJ to run.
from the library :
The sadam Library
Format : External
Environment : max / Max Runtime / msp
freeware
Max 5.x / 6.x


http://www.sadam.hu

4855 objects and 135 libraries within the database Last entries : December 23rd, 2023 Last comments : 0 0 visitor and 72716880 members connected RSS
Site under GNU Free Documentation License