DocumentTools
ContentToString
convert XML content to a worksheet string
Calling Sequence
Parameters
Description
Examples
Compatibility
ContentToString(content)
ContentToString(content, v)
content
-
{specfunc(_XML_Worksheet)} ; XML tree structure containing a valid XML representation of a complete worksheet
v
(optional) identical(validate)=truefalse; Whether to validate the XML against a schema. The default is false.
The ContentToString command converts an XML tree structure (content) to the string form of a worksheet file.
The content can be generated using commands from the Component Constructors and Layout Constructors packages. Such content can be inserted directly into the current window using the InsertContent command. The ContentToString command converts the content to a worksheet string.
The resulting worksheet string can be saved directly as a .mw format file, launched in a new window using the Worksheet:-Display command, or used with the CreateTask command.
with⁡DocumentTools:with⁡DocumentTools:-Layout
Cell,Column,DocumentBlock,Equation,Font,Group,Image,InlinePlot,Input,Output,Row,Section,Table,Textfield,Title,Worksheet
Using commands from the Layout Constructors package an XML tree representation of a full worksheet can be generated.
xml≔Worksheet⁡Group⁡Input⁡Table⁡Row⁡Some text.
xml≔_XML_Worksheet⁡_XML_Group⁡view=presentation,hide-input=false,hide-output=false,inline-output=false,drawlabel=true,_XML_Input⁡_XML_Table⁡interior=all,id=_Table_,hiddenborderdisplay=worksheet,showinput=true,alignment=left,exterior=all,width=100%,showlabel=false,captionalignment=0,title=,drawtitle=false,order=row,drawcaption=false,randomized=false,captionposition=1,showgroup=false,plotalignlists=,pagebreak=none,postexecute=advance,_XML_Table-Column⁡separator=true,weight=100,_XML_Table-Row⁡align=top,separator=true,_XML_Table-Cell⁡columnspan=1,backgroundstyle=0,rowspan=1,fillcolor=[255,255,255],visible=true,_XML_Text-field⁡alignment=centred,style=Text,layout=Normal,Some text.
The content xml could be inserted directly into the current window using the InsertContent command. It is also possible to save the generated content into a worksheet file or to open it in a new window, as the following examples illustrate.
The ContentToString command converts the content xml into the string form of a mw format file.
str≔ContentToString⁡xml
str≔<?xml version="1.0" encoding="UTF-8"?><Worksheet><Group view='presentation' hide-input='false' hide-output='false' inline-output='false' drawlabel='true'><Input><Table interior='all' id='_Table_' hiddenborderdisplay='worksheet' showinput='true' alignment='left' exterior='all' width='100%' showlabel='false' captionalignment='0' title='' drawtitle='false' order='row' drawcaption='false' randomized='false' captionposition='1' showgroup='false' plotalignlists='' pagebreak='none' postexecute='advance'><Table-Column separator='true' weight='100'/><Table-Row align='top' separator='true'><Table-Cell columnspan='1' backgroundstyle='0' rowspan='1' fillcolor='[255,255,255]' visible='true'><Text-field alignment='centred' style='Text' layout='Normal'>Some text.</Text-field></Table-Cell></Table-Row></Table></Input></Group></Worksheet>
The string representation of the worksheet can be opened in a new window using the Display command from the Worksheet package. Note that this package is referenced below using the global name :-Worksheet, since that name is also an export of the loaded DocumentTools:-Layout package.
:-Worksheet:-Display⁡str
The worksheet string can also be saved directly as a new worksheet file. In the following example a temporary filename is generated.
fname≔FileTools:-TemporaryFilename⁡cat⁡FileTools:-TemporaryDirectory⁡,/,.mw:FileTools:-Text:-WriteFile⁡fname,str:
That new worksheet file can also be opened directly.
:-Worksheet:-DisplayFile⁡fname
The DocumentTools[ContentToString] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
Component Constructors
CreateTask
Embedded Components
FileTools
InsertContent
Layout Constructors
Worksheet
Download Help Document