CleanXML - Maple Help

XMLTools

 CleanXML
 remove whitespace and comments from an XML tree

 Calling Sequence CleanXML(xmlTree)

Parameters

 xmlTree - Maple XML tree; XML element

Description

 • The CleanXML(xmlTree) command removes content consisting only of whitespace, as well as XML comment structures from an XML tree data structure. The return value is a cleaned XML tree data structure.
 • Strictly speaking, whitespace is significant in XML, but for some important applications (such as MathML and HTML) it is not.
 • Text content that is not completely whitespace is retained, but whitespace is canonicalized by removing all leading and trailing whitespace, and by collapsing internal sequences of whitespace characters to a single space character.
 • Whitespace in attribute values is also canonicalized.
 • For applications in which whitespace is not significant, and for which XML comments are not wanted, the XML tree data structure returned by this routine should have the same information as the input tree, but may be significantly reduced in size.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{xmlTree}≔\mathrm{XMLElement}\left("a",\left[\right],\left[\mathrm{XMLComment}\left("a comment"\right),"","Some text",\mathrm{XMLElement}\left("b",\left[\right],"More text",""\right)\right]\right)$
 ${\mathrm{xmlTree}}{≔}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Comment}}{}\left({"a comment"}\right){,}{\mathrm{_XML_Text}}{}\left({"Some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"More text"}\right)\right]\right)\right]\right)$ (1)
 > $\mathrm{CleanXML}\left(\mathrm{xmlTree}\right)$
 ${\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"Some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"More text"}\right)\right]\right)\right]\right)$ (2)