Serial (XmlDoc/XmlNode function): Difference between revisions
m (xpath expression) |
mNo edit summary |
||
Line 11: | Line 11: | ||
<td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression. If an <var>XmlDoc</var>, the <var>Root</var> node is the context node.</td></tr> | <td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression. If an <var>XmlDoc</var>, the <var>Root</var> node is the context node.</td></tr> | ||
<tr><th>xpath</th> | <tr><th>xpath</th> | ||
<td>A <var>Unicode</var> string that is an | <td>A <var>Unicode</var> string that is an [[XPath#XPath_syntax|Xpath expression]] that results in a nodelist, the head of which is the top of the subtree to serialize. This is an optional argument; its default is a period (<tt>.</tt>), that is, the node referenced by the method object(<var class="term">nr</var>). | ||
<p>Prior to <var class="product">[[Sirius Mods | <p>Prior to <var class="product">[[Sirius Mods]]</var> Version 7.6, this is an EBCDIC string.</p></td></tr> | ||
<tr><th>options</th> | <tr><th>options</th> | ||
<td>A blank delimited string that can contain one or more of the following options (but no repeats): | <td>A blank delimited string that can contain one or more of the following options (but no repeats): | ||
Line 38: | Line 38: | ||
</ul> | </ul> | ||
These options are described in greater detail in described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]</td></tr> | These options are described in greater detail in described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]</td></tr> | ||
<tr><th>AddTrailingDelimiter</th> | <tr><th><var>AddTrailingDelimiter</var></th> | ||
<td>This | <td>This [[Methods#Named parameters|name required]] parameter is a <var>[[Enumerations#Using Boolean enumerations|Boolean]]</var> value, which determines whether a final line-end character is added to the serialization when one of the <var>Serial</var> method line-end options (<var>LF</var>, <var>CR</var>, or <var>CRLF</var>) is specified. | ||
<p>The default value of <var>AddTrailingDelimiter</var> is < | <p>The default value of <var>AddTrailingDelimiter</var> is <var>True</var>, so <var>Serial</var> specified with a line-end option adds a trailing line-end by default. If <var>AddTrailingDelimiter</var> is <var>False</var>, no final line-end character is added.</p> | ||
<p>Specifying the <var>AddTrailingDelimiter</var> argument without also specifying one of the line-end options has no effect on the resulting serialization.</p> | <p>Specifying the <var>AddTrailingDelimiter</var> argument without also specifying one of the line-end options has no effect on the resulting serialization.</p> | ||
<p><var>AddTrailingDelimiter</var> was introduced as of <var class="product"> | <p><var>AddTrailingDelimiter</var> was introduced as of <var class="product">Sirius Mods</var> Version 7.0. It may be useful if a digital signature must be created which includes line-end characters between XML tags, but the <var>XmlDoc</var> does not contain those line-end <var>Text</var> nodes.</p></td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The <var class="term">options</var> argument values may be specified in any case. | <li>The <var class="term">options</var> argument values may be specified in any case. For example, <code>XmlDecl</code> and <code>xmldecl</code> are interchangeable. | ||
<li>As of <var class="product"> | <li>As of <var class="product">Sirius Mods</var> Version 7.6, <var>Attribute</var> values are always serialized within double-quotation-mark (<tt>"</tt>) delimiters, and a double-quotation mark character in an <var>Attribute</var> value is serialized as <code>&quot;</code>. Prior to <var class="product">Sirius Mods</var> Version 7.6, this convention was not strictly observed. | ||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
In the following example, the <var>Serial</var> method EBCDIC formatting of a document is shown. A <var>Print</var> statement display of the default UTF-8 formatting of <var>Serial</var> is a string that is not readily decipherable. | |||
<p class="code">begin | <p class="code">begin | ||
%doc is object xmlDoc | %doc is object xmlDoc | ||
Line 78: | Line 78: | ||
<p class="output">Serial method output follows: | <p class="output">Serial method output follows: | ||
<nowiki><top><a><b>05</b></a><c><d att="val"/></c></top></nowiki> | <nowiki><top><a><b>05</b></a><c><d att="val"/></c></top></nowiki> | ||
</p | </p> | ||
==Request-Cancellation Errors== | ==Request-Cancellation Errors== |
Revision as of 23:16, 23 May 2011
Serialize selected subtree as string (XmlDoc and XmlNode classes)
Serial converts an XmlDoc subtree to the UTF-8 or EBCDIC text string representation of the subtree. (This process is called serialization, because the text representation of a document is called the serial form.)
Syntax
%string = nr:Serial[( [xpath], [options], [AddTrailingDelimiter= boolean])] Throws XPathError
Syntax terms
%string | A string variable for the string serialization of the subtree, encoded either in UTF-8 or, if the EBCDIC option (see below) is used, in EBCDIC. |
---|---|
nr | An XmlDoc or XmlNode, used as the context node for the xpath expression. If an XmlDoc, the Root node is the context node. |
xpath | A Unicode string that is an Xpath expression that results in a nodelist, the head of which is the top of the subtree to serialize. This is an optional argument; its default is a period (.), that is, the node referenced by the method object(nr).
Prior to Sirius Mods Version 7.6, this is an EBCDIC string. |
options | A blank delimited string that can contain one or more of the following options (but no repeats):
|
AddTrailingDelimiter | This name required parameter is a Boolean value, which determines whether a final line-end character is added to the serialization when one of the Serial method line-end options (LF, CR, or CRLF) is specified.
The default value of AddTrailingDelimiter is True, so Serial specified with a line-end option adds a trailing line-end by default. If AddTrailingDelimiter is False, no final line-end character is added. Specifying the AddTrailingDelimiter argument without also specifying one of the line-end options has no effect on the resulting serialization. AddTrailingDelimiter was introduced as of Sirius Mods Version 7.0. It may be useful if a digital signature must be created which includes line-end characters between XML tags, but the XmlDoc does not contain those line-end Text nodes. |
Usage notes
- The options argument values may be specified in any case. For example,
XmlDecl
andxmldecl
are interchangeable. - As of Sirius Mods Version 7.6, Attribute values are always serialized within double-quotation-mark (") delimiters, and a double-quotation mark character in an Attribute value is serialized as
"
. Prior to Sirius Mods Version 7.6, this convention was not strictly observed.
Examples
In the following example, the Serial method EBCDIC formatting of a document is shown. A Print statement display of the default UTF-8 formatting of Serial is a string that is not readily decipherable.
begin %doc is object xmlDoc %sl is object stringlist %doc = new %sl = new text to %sl <top> <a> <b>05</b> </a> <c> <d att="val"/> </c> </top> end text Call %doc:loadXml(%sl) print 'Serial method output follows:' print %doc:serial('top', 'ebcdic') end
The example results follow:
Serial method output follows: <top><a><b>05</b></a><c><d att="val"/></c></top>
Request-Cancellation Errors
- xpath is invalid.
- Result of xpath is empty.
- An options setting is invalid.
- Insufficient free space exists in CCATEMP.
See also
- The subroutine that serializes an XmlDoc and sends it as a Web response is WebSend.
- Additional serializing methods include:
- Xml
- AddXml (HttpRequest class)
- To deserialize a string, use LoadXml or WebReceive.
- For more information about using XPath expressions, see "XPath".