Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Documentation / Mathematica / Add-ons & Links / XML Capabilities / Working with NotebookML / Syntax of NotebookML /

Data

There are several notebook elements for representing the different types of data that can occur in a notebook. These are described below.

TextData

Text that is potentially in different styles or that contains embedded cells, is represented in Mathematica as TextData. In NotebookML, it is represented by the TextData tag. Here is an example.

TextData[{"Some text",Cell[...],"some more text"}]

<TextData>

<String>Some text</String>

<Cell>...</Cell>

<String>Some more text</String>

</TextData>

TextData does not take any options—all of its children are its contents. Hence, there is no need for a TextDataContents wrapper element.

StyleData

Options for styles in a cell are contained in a StyleData element in Mathematica. As expected, this is represented by a StyleData element in NotebookML. Here are two basic templates, depending on whether a particular style environment is specified or not.

StyleData[style_String]

<StyleData>

<String>style</String>

</StyleData>

StyleData[style_String, environment_String]

<StyleData>

<String>style</String>

<String>environment</String>

</StyleData>

BoxData

In addition to being expressed as NotebookML, the contents of a BoxData expression can also be saved as MathML or a GIF file. If it is saved as MathML, then the BoxData element contains MathML wrapped in a math tag. If it is saved as a GIF image, then the content is an img element like XHTML, with the appropriate references.

For example, here is a BoxData fragment exported as MathML.

<BoxData>

<math>

<mrow>

...

</mrow>

</math>

</BoxData>

Here is BoxData fragment exported as a GIF image.

<BoxData>

<img src="/Images/img1.gif"/>

</BoxData>

GraphicsData

In addition to being a NotebookML expression, a GraphicsData expression can also be saved as a GIF file. When saved as NotebookML, the GraphicsData element wraps the data in an element whose name is the encoding type. When saved as a GIF, the GraphicsData element has only a img element like XHTML that references the GIF.

Here, for example, is a GraphicsData fragment exported as NotebookML.

<GraphicsData>

<PostScript> ... postscript data here ...</PostScript>

</GraphicsData>

Here, on the other hand, is a GraphicsData fragment exported as a GIF image.

<GraphicsData>

<img src="/Images/img1.gif"/>

<GraphicsData>

CellGroupData

Closed or open cell groups are represented by the CellGroupData tag.

CellGroupData[contents_List, Open|Closed]

<CellGroupData>

<CellGroupDataContents>

...

</CellGroupDataContents>

<Symbol>[Open|Closed]</Symbol>

</CellGroupData>

OutputFormData

In Mathematica, OutputFormData contains text as generated by InputForm and OutputForm. It is represented in NotebookML by the tag OutputFormData with the following basic template, where input is a string representing the input form and output is a string representing the output form.

OutputFormData[input, output]

<OutputFormData>

<String>...</String>

<String>...</String>

</OutputFormData>

As in Mathematica, the string that represents the output form and the string that represents the input form are determined positionally; the first child is the input form, the second is the output form.

XMLData

One potential benefit of XML formats is the ability to use multiple programs for authoring single documents. By using XML as an interchange format, the document should be editable by many programs. However, just because the files are in XML format, does not necessarily mean all programs will know what to do with the XML; there still must be a way to hold onto the unrecognized XML portions in other applications.

Raw SymbolicXML can be entered under an XMLData suboption for the TaggingRules option. This allows you to add arbitrary SymbolicXML into your notebooks or, if you are generating NotebookML from some other means, additional XML code. After importing the NotebookML document, your XML is stored in the notebook under this option. Any part of TaggingRules that is not under the "XMLData" suboption is saved as ExpressionML, as it can represent arbitrary Mathematica expressions.

For example, suppose you are authoring a document that uses MathML and VoiceML. Naturally, Mathematica would be an excellent environment for editing the MathML portion of such a document. However, chances are there is a better editing environment for VoiceML. It is therefore useful to retain the VoiceML data in a notebook. Even if that information is never used by the front end itself, it needs to be present so that it is still available after exporting to XML.

Here, we have a simple example that shows TaggingRules being used on a cell. The XML data is rendered in an XMLData element.

Cell["Some text",TaggingRulesRule{"val","XMLData"Rule{XMLElement["voice",{},{}]},1}]

This is how the above cell would be represented in ExpressionML.

<Cell>

<String>Some text</String>

<Options>

<Option>

<Symbol>TaggingRules</Symbol>

<Function>

<Symbol>List</Symbol>

<String>val</String>

<XMLData>

<voice/>

</XMLData>

<Number>1</Number>

</Function>

</Option>

</Options>

</Cell>



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information


 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy | [ja] |
Sign up for our newsletter: