<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMPrint</code>( <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>OMPrint writes the default XML <strong class="pkg">OpenMath</strong> encoding of <strong class="pkg">GAP</strong> object <var class="Arg">obj</var> to the standard output.</p>
<p>One can try it with different <strong class="pkg">GAP</strong> objects to see if they can be converted to <strong class="pkg">OpenMath</strong> and learn how their <strong class="pkg">OpenMath</strong> representation looks like. Here we show the encoding for lists of integers and rationals:</p>
<p>Strings are encoded using <code class="code"><OMSTR></code> tags:</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">OMPrint( "This is a string" );</span>
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMSTR>This is a string</OMSTR>
</OMOBJ>
</pre></div>
<p>Cyclotomics may be encoded in different ways dependently on their properties:</p>
<p>Producing <strong class="pkg">OpenMath</strong> representation of polynomials, one may get a warning:</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=Indeterminate(Rationals,"x");; y:=Indeterminate(Rationals,"y");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">OMPrint(x^2+y);</span>
#I Warning : polynomial will be printed using its default ring
#I because the default OpenMath polynomial ring is not specified
#I or it is not contained in the default OpenMath polynomial ring.
#I You may ignore this or call SetOpenMathDefaultPolynomialRing to fix it.
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA>
<OMS cd="polyd1" name="DMP"/>
<OMA id="polyring9qiY2oOaiITWUORb" >
<OMS cd="polyd1" name="poly_ring_d"/>
<OMS cd="setname1" name="Q"/>
<OMI>2</OMI>
</OMA>
<OMA>
<OMS cd="polyd1" name="SDMP"/>
<OMA>
<OMS cd="polyd1" name="term"/>
<OMI>1</OMI>
<OMI>0</OMI>
<OMI>1</OMI>
</OMA>
<OMA>
<OMS cd="polyd1" name="term"/>
<OMI>1</OMI>
<OMI>2</OMI>
<OMI>0</OMI>
</OMA>
</OMA>
</OMA>
</OMOBJ>
</pre></div>
<p>Indeed, now when another polynomial will be printed, it will belong to a ring with a different identifier (despite <strong class="pkg">GAP</strong> will be able to perform arithmetical operations on these polynomials like when they belong to the same ground ring):</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">OMPrint(x+1);</span>
#I Warning : polynomial will be printed using its default ring
#I because the default OpenMath polynomial ring is not specified
#I or it is not contained in the default OpenMath polynomial ring.
#I You may ignore this or call SetOpenMathDefaultPolynomialRing to fix it.
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA>
<OMS cd="polyd1" name="DMP"/>
<OMA id="polyring0LqlkhnCyLldcoBl" >
<OMS cd="polyd1" name="poly_ring_d_named"/>
<OMS cd="setname1" name="Q"/>
<OMV name="x"/>
</OMA>
<OMA>
<OMS cd="polyd1" name="SDMP"/>
<OMA>
<OMS cd="polyd1" name="term"/>
<OMI>1</OMI>
<OMI>1</OMI>
</OMA>
<OMA>
<OMS cd="polyd1" name="term"/>
<OMI>1</OMI>
<OMI>0</OMI>
</OMA>
</OMA>
</OMA>
</OMOBJ>
</pre></div>
<p>Thus, the warning means that it is not guaranteed that the polynomial ring will have the same identifier <code class="code"><OMA id="polyring..." ></code> when another or same polynomial from this ring will be printed next time. If this may constitute a problem, for example, if a list of polynomial is being exchanged with another system and it is crucial that all of them will belong to the same ring, then such ring must be created explicitly and then <code class="code">SetOpenMathDefaultPolynomialRing</code> must be called:</p>
<p>Now we can see that both polynomials belong to the ring with the same identifier, and the <strongclass="pkg">OpenMath</strong> representation of the 2nd polynomial properly reflects that it belongs to a polynomial ring with two variables.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMString</code>( <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>OMString returns a string with the default XML <strong class="pkg">OpenMath</strong> encoding of <strong class="pkg">GAP</strong> object <var class="Arg">obj</var>. If used with the <code class="keyw">noomobj</code> option, then initial and final <OMOBJ> tags will be omitted.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMGetObject</code>( <var class="Arg">stream</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><var class="Arg">stream</var> is an input stream (see <code class="func">InputTextFile</code> (<a href="../../../doc/ref/chap10_mj.html#X8343D04981128784"><span class="RefLink">Reference: InputTextFile</span></a>), <code class="func">InputTextUser</code> (<a href="../../../doc/ref/chap10_mj.html#X83531E4C7C53544F"><span class="RefLink">Reference: InputTextUser</span></a>), <code class="func">InputTextString</code> (<a href="../../../doc/ref/chap10_mj.html#X7ABABCDF7ED81F7F"><span class="RefLink">Reference: InputTextString</span></a>), <code class="func">InputOutputLocalProcess</code> (<a href="../../../doc/ref/chap10_mj.html#X820799A3824684AC"><span class="RefLink">Reference: InputOutputLocalProcess</span></a>), <code class="func">InputOutputTCPStream</code> (<a href="../../../pkg/scscp/doc/chap3_mj.html#X7E3D43CF7B049F04"><span class="RefLink">SCSCP: InputOutputTCPStream for client</span></a>), <code class="func">InputOutputTCPStream</code> (<a href="../../../pkg/scscp/doc/chap3_mj.html#X7E3D43CF7B049F04"><span class="RefLink">SCSCP: InputOutputTCPStream for server</span></a>)) with an <strong class="pkg">OpenMath</strong> object on it. <code class="func">OMGetObject</code> takes precisely one object off <var class="Arg">stream</var> and returns it as a GAP object. Both XML and binary <strong class="pkg">OpenMath</strong> encoding are supported: autodetection is used.</p>
<p>This may be used to retrieve objects from a file. In the following example we demonsrate reading the same content in binary and XML formats using the test files supplied with the package (the package autodetects whether binary or XML encoding is used):</p>
<p>For XML <strong class="pkg">OpenMath</strong>, this function requires that the <strong class="pkg">GAP</strong> package <strong class="pkg">GAPDoc</strong> is available.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EvalOMString</code>( <var class="Arg">omstr</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function is an analog of <code class="func">EvalString</code> (<a href="../../../doc/ref/chap27_mj.html#X7DE4CCD285440659"><span class="RefLink">Reference: EvalString</span></a>). Its argument <var class="Arg">omstr</var> must be a string containing a single <strong class="pkg">OpenMath</strong> object. <code class="func">EvalOMString</code> will return the <strong class="pkg">GAP</strong> object represented by <var class="Arg">omstr</var>.</p>
<p>If <var class="Arg">omstr</var> contains more <strong class="pkg">OpenMath</strong> objects, the rest will be ignored.</p>
<h4>2.3 <span class="Heading">Writing <strong class="pkg">OpenMath</strong> code to streams</span></h4>
<p>While it is possible to read <strong class="pkg">OpenMath</strong> code directly from a stream, writing <strong class="pkg">OpenMath</strong> to streams uses a different setup. It requires special objects called <strong class="pkg">OpenMath</strong> <em>writers</em>, which encapsulate streams and may be viewed as transducers accepting <strong class="pkg">GAP</strong> objects and writing them to a stream in the XML or binary <strong class="pkg">OpenMath</strong></p>
<p>Such setup makes it possible to re-use the same stream for both binary and XML <strong class="pkg">OpenMath</strong> communication, using different <strong class="pkg">OpenMath</strong> writers in different calls. It also allows to re-use most of the high-level code for <strong class="pkg">GAP</strong> to <strong class="pkg">OpenMath</strong> conversion, having separate methods for generating binary and XML <strong class="pkg">OpenMath</strong> only for low-level output (<strong class="pkg">OpenMath</strong> tags and basic objects). This makes easier adding support to new mathematical objects and private content dictionaries as described in Chapter <a href="chap3_mj.html#X795882BD7DC3B2E4"><span class="RefLink">3</span></a> since it does not require changing the low-level functionality.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMPutObject</code>( <var class="Arg">stream</var>, <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMPutObjectNoOMOBJtags</code>( <var class="Arg">stream</var>, <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">OMPutObject</code> writes (appends) the XML <strong class="pkg">OpenMath</strong> encoding of the <strong class="pkg">GAP</strong> object <var class="Arg">obj</var> to outputstream <var class="Arg">stream</var> (see <code class="func">InputTextFile</code> (<a href="../../../doc/ref/chap10_mj.html#X8343D04981128784"><span class="RefLink">Reference: InputTextFile</span></a>), <code class="func">OutputTextUser</code> (<a href="../../../doc/ref/chap10_mj.html#X83E5FC9487766297"><span class="RefLink">Reference: OutputTextUser</span></a>), <code class="func">OutputTextString</code> (<a href="../../../doc/ref/chap10_mj.html#X7FEDA5167979B74D"><span class="RefLink">Reference: OutputTextString</span></a>), <code class="func">InputOutputTCPStream</code> (<a href="../../../pkg/scscp/doc/chap3_mj.html#X7E3D43CF7B049F04"><span class="RefLink">SCSCP: InputOutputTCPStream for client</span></a>), <code class="func">InputOutputTCPStream</code> (<a href="../../../pkg/scscp/doc/chap3_mj.html#X7E3D43CF7B049F04"><span class="RefLink">SCSCP: InputOutputTCPStream for server</span></a>)).</p>
<p>The second version does the same but without <OMOBJ> tags, what may be useful for assembling complex <strong class="pkg">OpenMath</strong> objects.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMPlainString</code>( <var class="Arg">string</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">OMPlainString</code> wraps the string into a <strong class="pkg">GAP</strong> object of a special kind called an <strong class="pkg">OpenMath</strong> plain string. Internally such object is represented as a string, but <code class="func">OMPutObject</code> (<a href="chap2_mj.html#X84FC6AD5872CBF33"><span class="RefLink">2.3-4</span></a>) threat it in a different way: instead of converting it into a <OMSTR> object, an <strong class="pkg">OpenMath</strong> plain string will be plainly substituted into the output (this explains its name) without decorating it with <OMSTR> tags.</p>
<p>It is assumed that <strong class="pkg">OpenMath</strong> plain string contains valid <strong class="pkg">OpenMath</strong> code; no actual validation is performed during its creation. Such functionality may be useful to compose some <strong class="pkg">OpenMath</strong> code at the <strong class="pkg">GAP</strong> level to communicate it to the other system, in particular, to send there symbols which are not supported by <strong class="pkg">GAP</strong>, for example:</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMTestXML</code>( <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMTest</code>( <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Converts <var class="Arg">obj</var> to XML <strong class="pkg">OpenMath</strong> and back. Returns true if and only if <var class="Arg">obj</var> is unchanged (as a <strong class="pkg">GAP</strong> object) by this operation. The <strong class="pkg">OpenMath</strong> standard does not stipulate that converting to and from <strong class="pkg">OpenMath</strong> should be the identity function so this is a useful diagnostic tool.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OMTestBinary</code>( <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Converts <var class="Arg">obj</var> to binary <strong class="pkg">OpenMath</strong> and back. Returns true if and only if <var class="Arg">obj</var> is unchanged (as a <strong class="pkg">GAP</strong> object) by this operation. The <strong class="pkg">OpenMath</strong> standard does not stipulate that converting to and from <strong class="pkg">OpenMath</strong> should be the identity function so this is a useful diagnostic tool.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.