ApplyElement - Maple Help

XMLTools

 ApplyElement
 process all occurrences of a given element

 Calling Sequence ApplyElement(xmlTree, elementName, rator)

Parameters

 xmlTree - Maple XML tree; XML document elementName - string; the name of the element rator - anything (typically a procedure); operator to apply

Description

 • The ApplyElement(xmlTree, elementName, rator) command processes each occurrence of an element named elementName in the given tree xmlTree using rator. An XML tree, with each occurrence of an element named elementName replaced by the result of calling rator with that element as argument, is returned.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{doc}≔\mathrm{XMLElement}\left("doc",\left[\right],\left[\mathrm{XMLElement}\left("title",\left[\right],"This is the title"\right),\mathrm{XMLElement}\left("body",\left[\right],"This is the body of the document"\right)\right]\right):$
 > $\mathrm{Print}\left(\mathrm{doc}\right)$
   This is the title   This is the body of the document
 > Print( ApplyElement( doc, "title",     proc( elt )         XMLElement( "title",             Attributes( elt ),             XMLElement( "b", [], ContentModel( elt ) ) )     end ) );
        <b>This is the title</b>      This is the body of the document
 > $\mathrm{Print}\left(\mathrm{ApplyElement}\left(\mathrm{doc},"title",\mathrm{elt}↦\mathrm{XMLElement}\left("center",\left[\right],\mathrm{elt}\right)\right)\right)$

This is the title
This is the body of the document