ContentModel - Maple Help

XMLTools

 ContentModel
 extract the content model of an XML element
 ContentModelCount
 count the number of children of an XML element

 Calling Sequence ContentModel(xmlTree) ContentModelCount(xmlTree)

Parameters

 xmlTree - Maple XML tree; XML element

Description

 • The ContentModel(xmlTree) command returns the content model of the XML element xmlTree. The data is returned in the form of a list of strings or a list of XML trees, and it occurs in the same order as in the input element.
 Note: To remove all the attributes of element xmlTree, leaving the attributes of any subelements unchanged, use XMLElement( ElementName(xmlTree), [], ContentModel(xmlTree)).
 • The ContentModelCount(xmlTree) command counts the number of children (attributes are not counted) of the XML element xmlTree. The number of children is returned as a non-negative integer.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{ContentModel}\left(\mathrm{XMLElement}\left("a"\right)\right)$
 $\left[\right]$ (1)
 > $\mathrm{ContentModel}\left(\mathrm{XMLElement}\left("a",\left["foo"="bar"\right]\right)\right)$
 $\left[\right]$ (2)
 > $\mathrm{xmlTree}≔\mathrm{XMLElement}\left("a",\left["colour"="red"\right],\left[\mathrm{XMLElement}\left("b",\left["size"="2"\right],"some text"\right),"more text"\right]\right):$
 > $\mathrm{ContentModel}\left(\mathrm{xmlTree}\right)$
 $\left[{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[{\mathrm{_XML_Attribute}}{}\left({\mathrm{_XML_AttrName}}{}\left({"size"}\right){,}{\mathrm{_XML_AttrValue}}{}\left({"2"}\right)\right)\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"some text"}\right)\right]\right){,}{\mathrm{_XML_Text}}{}\left({"more text"}\right)\right]$ (3)
 > $\mathrm{ContentModelCount}\left(\mathrm{XMLElement}\left("a"\right)\right)$
 ${0}$ (4)
 > $\mathrm{ContentModelCount}\left(\mathrm{XMLElement}\left("a",\left["foo"="bar"\right]\right)\right)$
 ${0}$ (5)
 > $\mathrm{ContentModelCount}\left(\mathrm{XMLElement}\left("a",\left[\right],\left["one","two","three"\right]\right)\right)$
 ${1}$ (6)
 > $\mathrm{ContentModelCount}\left(\mathrm{xmlTree}\right)$
 ${2}$ (7)