Print (XmlDoc/XmlNode subroutine): Difference between revisions
m (→Syntax terms) |
m (→See also) |
||
Line 102: | Line 102: | ||
==See also== | ==See also== | ||
<ul> | <ul> | ||
<li>For more information about using XPath expressions, see [[XPath | <li>For more information about using XPath expressions, see [[XPath]]. | ||
<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. | <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. | ||
<li>See the description of [[XmlDoc_API_serialization_options#EBCDIC_serialization_of_untranslatable_Unicode_characters|Unicode to EBCDIC conversion]] performed by <var>Print</var>. | <li>See the description of [[XmlDoc_API_serialization_options#EBCDIC_serialization_of_untranslatable_Unicode_characters|Unicode to EBCDIC conversion]] performed by <var>Print</var>. | ||
<li>For additional discussion about serialization, see [[XmlDoc API#Transport: receiving and sending XML|Transport: receiving and sending XML]].</li> | |||
<li>Additional serializing methods include: | <li>Additional serializing methods include: |
Revision as of 20:45, 13 March 2014
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. Note: These options are 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>
- In the following fragment, the Print result for a document with untranslatable Unicode is shown:
%doc2:addElement('circumference', '2 * π * r':U) %doc2:print
The result follows (the Unicode codepoint for the Greek letter π has the hexadecimal value 03C0):
<circumference>2 * π * r</circumference>
Request-cancellation errors
This list is not exhaustive: it does not include all the errors that are request cancelling.
- The xpath expression is invalid.
- The 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.
- See the description of Unicode to EBCDIC conversion performed by Print.
- For additional discussion about serialization, see Transport: receiving and sending XML.
- Additional serializing methods include:
- WebSend
- AddXml (HttpRequest class)