 Worksheet - Maple Programming Help

Home : Support : Online Help : Connectivity : Web Features : Worksheet Package : Worksheet/ToString

Worksheet

 ToString
 convert a XML tree data structure representing a worksheet in the specified format and return it as a Maple string

 Calling Sequence ToString(xmlTree, format=output_format)

Parameters

 xmlTree - Maple XML tree; worksheet format=output_format - (optional) equation; output_format can be one of "mws", "maple8_xml", or "mw" (default)

Description

 • The ToString(xmlTree) calling sequence formats the XML document xmlTree representing a Maple worksheet as a MWS document (stored as a Maple string).
 It is assumed that the XML document that is written to a string represents a valid worksheet. (Maple performs only a surface check.)
 The returned XML document is formatted without line breaking or indentation of any kind. As a result, regardless of size, the document is returned as a single line of text.

Examples

The following examples demonstrate how a Maple XML tree data structure can be converted and returned as a string.

The ToString command converts the XML tree data structure doc and returns it as a Maple string str.

 > $\mathrm{with}\left(\mathrm{Worksheet}\right):$
 > $\mathrm{str}≔"\left\{VERSION 5 0 \"SUN SPARC SOLARIS\" \"5.0\" \right\}\left\{USTYLETAB \right\}\left\{SECT 0 \left\{EXCHG \left\{PARA 0 \"\" 0 \"\" \left\{TEXT -1 21 \"Very simple worksheet\" \right\}\right\}\left\{PARA 0 \"> \" 0 \"\"\left\{MPLTEXT 1 0 16 \"with\left(Worksheet\right);\"\right\}\right\}\right\}\left\{EXCHG \left\{PARA 0 \"> \" 0 \"\" \left\{MPLTEXT 1 0 0 \"\" \right\}\right\}\right\}\right\}\left\{MARK \"1 0 0\" 0 \right\}\left\{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 \right\}\left\{PAGENUMBERS 0 1 2 33 1 1 \right\}"$
 ${\mathrm{str}}{≔}{"\left\{VERSION 5 0 "SUN SPARC SOLARIS" "5.0" \right\}\left\{USTYLETAB \right\}\left\{SECT 0 \left\{EXCHG \left\{PARA 0 "" 0 "" \left\{TEXT -1 21 "Very simple worksheet" \right\}\right\}\left\{PARA 0 "> " 0 ""\left\{MPLTEXT 1 0 16 "with\left(Worksheet\right);"\right\}\right\}\right\}\left\{EXCHG \left\{PARA 0 "> " 0 "" \left\{MPLTEXT 1 0 0 "" \right\}\right\}\right\}\right\}\left\{MARK "1 0 0" 0 \right\}\left\{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 \right\}\left\{PAGENUMBERS 0 1 2 33 1 1 \right\}"}$ (1)
 > $\mathrm{doc}≔\mathrm{FromString}\left(\mathrm{str}\right):$
 > $\mathrm{str1}≔\mathrm{ToString}\left(\mathrm{doc},\mathrm{format}="mws"\right):$
 > $\mathrm{str2}≔\mathrm{ToString}\left(\mathrm{doc},\mathrm{format}="maple8_xml"\right):$
 > $\mathrm{str3}≔\mathrm{ToString}\left(\mathrm{doc},\mathrm{format}="mw"\right):$

The string str is parsed and converted back to an XML tree data structure doc1 by using the FromString command.

 > $\mathrm{doc1}≔\mathrm{FromString}\left(\mathrm{str}\right):$

The Display command launches the worksheets. The Display command launches the string str and the XML tree doc1. For information on Display command parameters, see Worksheet[Display].

 > $\mathrm{Display}\left(\mathrm{str}\right):$
 > $\mathrm{Display}\left(\mathrm{doc1}\right):$