To String - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

Worksheet

  

ToString

  

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

 

Calling Sequence

Parameters

Description

Examples

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).

• 

The xmlTree argument can either be the full document as read from a worksheet file, or a worksheet resulting from a call to DocumentTools:-Layout:-Worksheet (containing calls to other DocumentTools:-Layout and DocumentTools:-Components commands).

  

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.

withWorksheet:

str{VERSION 5 0 \"SUN SPARC SOLARIS\" \"5.0\" }{USTYLETAB }{SECT 0 {EXCHG {PARA 0 \"\" 0 \"\" {TEXT -1 21 \"Very simple worksheet\" }}{PARA 0 \"> \" 0 \"\"{MPLTEXT 1 0 16 \"with(Worksheet);\"}}}{EXCHG {PARA 0 \"> \" 0 \"\" {MPLTEXT 1 0 0 \"\" }}}}{MARK \"1 0 0\" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }

str{VERSION 5 0 "SUN SPARC SOLARIS" "5.0" }{USTYLETAB }{SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "Very simple worksheet" }}{PARA 0 "> " 0 ""{MPLTEXT 1 0 16 "with(Worksheet);"}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "1 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }

(1)

docFromStringstr:

str1ToStringdoc,format=mws:

str2ToStringdoc,format=maple8_xml:

str3ToStringdoc,format=mw:

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

doc1FromStringstr3:

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].

Displaystr:

Displaydoc1:

To generate a similar document using the DocumentTools:-Layout commands, we can proceed as follows.

withDocumentTools:-Layout:

txtTextfieldVery simple worksheet,alignment=left

txt_XML_Text-fieldalignment=left,style=Text,layout=Normal,Very simple worksheet

(2)

withstmtTextfieldwith(Worksheet);,alignment=left,layout=Maple,prompt=> ,style=MapleInput

withstmt_XML_Text-fieldprompt=> ,alignment=left,style=Maple Input,layout=Maple Output,with(Worksheet);

(3)

emptystmtTextfieldalignment=left,layout=Maple,prompt=> ,style=MapleInput

emptystmt_XML_Text-fieldprompt=> ,alignment=left,style=Maple Input,layout=Maple Output

(4)

dxmlWorksheetGroupInputtxt,Inputwithstmt,Groupemptystmt

dxml_XML_Worksheet_XML_Groupview=presentation,hide-input=false,hide-output=false,inline-output=false,drawlabel=true,_XML_Input_XML_Text-fieldalignment=left,style=Text,layout=Normal,Very simple worksheet,_XML_Input_XML_Text-fieldprompt=> ,alignment=left,style=Maple Input,layout=Maple Output,with(Worksheet);,_XML_Groupview=presentation,hide-input=false,hide-output=false,inline-output=false,drawlabel=true,_XML_Text-fieldprompt=> ,alignment=left,style=Maple Input,layout=Maple Output

(5)

dstrToStringdxml

dstr<Worksheet><Group view='presentation' hide-input='false' hide-output='false' inline-output='false' drawlabel='true'><Input><Text-field alignment='left' style='Text' layout='Normal'>Very simple worksheet</Text-field></Input><Input><Text-field prompt='> ' alignment='left' style='Maple Input' layout='Maple Output'>with(Worksheet);</Text-field></Input></Group><Group view='presentation' hide-input='false' hide-output='false' inline-output='false' drawlabel='true'><Text-field prompt='> ' alignment='left' style='Maple Input' layout='Maple Output'/></Group></Worksheet>

(6)

Displaydstr

See Also

Worksheet

Worksheet[FromString]

XMLTools

 


Download Help Document