Print (XmlDoc/XmlNode subroutine): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (match syntax table to syntax template, tags and edits) |
||
Line 1: | Line 1: | ||
{{Template:XmlDoc/XmlNode:Print subtitle}} | {{Template:XmlDoc/XmlNode:Print subtitle}} | ||
The <var>Print</var> subroutine displays an <var>XmlDoc</var> subtree in a readable form, useful for debugging, for example. | |||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc/XmlNode:Print syntax}} | {{Template:XmlDoc/XmlNode:Print syntax}} | ||
Line 8: | Line 7: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>nr</th> | <tr><th>nr</th> | ||
<td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the [[XPath#XPath_syntax|XPath 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 [[XPath#XPath_syntax|XPath 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 XPath expression that results in a nodelist, the head of which is the top of the subtree to print. An optional argument, its default is a period (< | <td>A <var>Unicode</var> string that is an XPath expression that results in a <var>nodelist</var>, the head of which is the top of the subtree to print. An optional argument, its default is a period (<code>.</code>), that is, the node referenced by the method object (<var class="term">nr</var>).</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, which are identified below and described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]: | <td>A blank delimited string that can contain one or more of the following options, which are identified below and described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]: | ||
<ul> | <ul> | ||
<li><b>AllowXmlDecl</b> or <b>NoXmlDecl</b><br> | <li><b>AllowXmlDecl</b> or <b>NoXmlDecl</b><br> | ||
Whether or not the serialization will contain the "XML Declaration" (<code><?xml version=...?></code>), if the value of the <var>[[Version (XmlDoc property)|Version]]</var> property is a non-null string, if the <var>XmlDoc</var> is not empty, | Whether or not the serialization will contain the "XML Declaration" (<code><?xml version=...?></code>), if the value of the <var>[[Version (XmlDoc property)|Version]]</var> property is a non-null string, if the <var>XmlDoc</var> is not empty, and if the node selected by <var class="term">xpath</var> is the <var>Root</var> node. <var>AllowXmlDecl</var> is the default. | ||
and if the node selected by <var class="term">xpath</var> is the <var>Root</var> node. <var>AllowXmlDecl</var> is the default. | |||
<li><b>CharacterEncodeAll</b><br> | <li><b>CharacterEncodeAll</b><br> | ||
Line 29: | Line 26: | ||
<li><b>NoEmptyElt</b><br> | <li><b>NoEmptyElt</b><br> | ||
Deprecated as of <var class="product">Sirius Mods</var> | Deprecated as of <var class="product">[[Sirius Mods]]</var> Version 7.0, serializes all empty elements with a start tag followed by an end tag. The default is to serialize an empty element with an empty element tag (as in <code><middleName/></code>). | ||
<li><b>OmitNullElement</b><br> | <li><b>OmitNullElement</b><br> | ||
Line 41: | Line 38: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>Options may be specified in any case. | <li>Options may be specified in any case. For example, you can use either <code>NoXmlDecl</code> or <code>noxmldecl</code>, interchangeably. | ||
For example, you can use | <li>As a debugging aide, <var>Print</var> may be issued for the root node of an <var>XmlDoc</var> that is not well-formed, that is, does not contain an <var>Element</var>. | ||
either <code>NoXmlDecl</code> or <code>noxmldecl</code>, interchangeably. | <li>As of <var class="product">Sirius Mods</var> Version 7.6, <var>Attribute</var> values are always serialized within double-quotation-mark (<code>"</code>) delimiters, and a double-quotation mark character in an attribute value is serialized as <code>&quot;</code>. Prior to <var class="product">Sirius Mods</var> Version 7.6, this convention was not strictly observed. | ||
<li>As a debugging aide, <var>Print</var> may be issued for the root node of an | |||
<var>XmlDoc</var> that is not well-formed, that is, does not contain an <var>Element</var>. | |||
<li>As of <var class="product">Sirius Mods</var> | |||
within double-quotation-mark (< | |||
and a double-quotation mark character in an attribute value is serialized | |||
as <code>&quot;</code>. | |||
Prior to | |||
</ul> | </ul> | ||
== | ==Examples== | ||
<ol><li>In the following example, the <var>Print</var> method is called first in its default form with no arguments, then with explicit values for its options: | |||
In the following example, the <var>Print</var> method is called first | <p class="code">begin | ||
in its default form with no arguments, | print 'Print method' | ||
then with explicit values for its options: | print '***********' | ||
<p class="code"> | %doc is object xmlDoc | ||
%doc = new | |||
[[Notation_conventions_for_methods#Callable_methods|call]] %doc:[[LoadXml_(XmlDoc/XmlNode_function)|loadXml]]<nowiki>('<top><a><b>05</b></a><a2/></top>')</nowiki> | |||
%doc:[[Version (XmlDoc property)|Version]] ='1.0' | |||
call %doc:print | |||
print 'Non-default display:' | |||
call %doc:print('/', 'NoXmlDecl NoEmptyElt Indent 6 Expanded') | |||
end | |||
</p> | </p> | ||
The example results follow: | The example results follow: | ||
<p class=" | <p class="output"> <nowiki><?xml version="1.0"?> | ||
<top> | <top> | ||
<a> | <a> | ||
Line 90: | Line 75: | ||
</a2> | </a2> | ||
</top></nowiki> | </top></nowiki> | ||
</p> | </p></ol> | ||
==Request-cancellation errors== | ==Request-cancellation errors== | ||
<ul> | <ul> | ||
Line 98: | Line 84: | ||
<li>Insufficient free space exists in CCATEMP. | <li>Insufficient free space exists in CCATEMP. | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
<ul> | <ul> | ||
<li>For more information about using XPath expressions, see [[XPath|"XPath"]]. | <li>For more information about using XPath expressions, see [[XPath|"XPath"]]. | ||
<li>To more accurately serialize an <var>XmlDoc</var>, as opposed to providing | <li>To more accurately serialize an <var>XmlDoc</var>, as opposed to providing a "displayable" form, use the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> function. The <var>Print</var> subroutine, like its analogs <var>[[Audit (XmlDoc/XmlNode subroutine)|Audit]]</var> and <var>[[Trace (XmlDoc/XmlNode subroutine)|Trace]]</var>, inserts line breaks and performs indentation. | ||
a "displayable" form, use the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> function. | |||
The <var>Print</var> subroutine, like its analogs <var>[[Audit (XmlDoc/XmlNode subroutine)|Audit]]</var> | |||
and <var>[[Trace (XmlDoc/XmlNode subroutine)|Trace]]</var>, inserts line breaks and performs indentation. | |||
<li>Additional serializing methods include: | <li>Additional serializing methods include: | ||
<ul> | <ul> | ||
Line 114: | Line 95: | ||
</ul> | </ul> | ||
</ul> | </ul> | ||
{{Template:XmlDoc/XmlNode:Print footer}} |
Revision as of 03:39, 29 May 2011
Print selected subtree (XmlDoc and XmlNode classes)
The Print subroutine displays an XmlDoc subtree in a readable form, useful for debugging, for example.
Syntax
nr:Print[( [xpath], [options])] Throws XPathError
Syntax terms
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 print. An optional argument, its default is a period (. ), that is, the node referenced by the method object (nr). |
options | A blank delimited string that can contain one or more of the following options, which are identified below and described in greater detail in "XmlDoc API serialization options":
|
Usage notes
- Options may be specified in any case. For example, you can use either
NoXmlDecl
ornoxmldecl
, interchangeably. - As a debugging aide, Print may be issued for the root node of an XmlDoc that is not well-formed, that is, does not contain an Element.
- 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 Print method is called first in its default form with no arguments, then with explicit values for its options:
begin print 'Print method' print '***********' %doc is object xmlDoc %doc = new call %doc:loadXml('<top><a><b>05</b></a><a2/></top>') %doc:Version ='1.0' call %doc:print print 'Non-default display:' call %doc:print('/', 'NoXmlDecl NoEmptyElt Indent 6 Expanded') end
The example results follow:
<?xml version="1.0"?> <top> <a> <b>05</b> </a> <a2/> </top> Non-default display: <top> <a> <b> 05 </b> </a> <a2> </a2> </top>
Request-cancellation errors
- xpath is invalid.
- Result of xpath is empty.
- options values are invalid.
- Insufficient free space exists in CCATEMP.
See also
- For more information about using XPath expressions, see "XPath".
- To more accurately serialize an XmlDoc, as opposed to providing a "displayable" form, use the Serial function. The Print subroutine, like its analogs Audit and Trace, inserts line breaks and performs indentation.
- Additional serializing methods include:
- WebSend
- AddXml (HttpRequest class)