WebSend (XmlDoc subroutine): Difference between revisions
mNo edit summary |
m (→See also) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 11: | Line 11: | ||
<tr><th>doc</th> | <tr><th>doc</th> | ||
<td>An expression that points to the <var>XmlDoc</var> whose content is to be serialized. </td></tr> | <td>An expression that points to the <var>XmlDoc</var> whose content is to be serialized. </td></tr> | ||
<tr><th>options</th> | <tr><th>options</th> | ||
<td>A blank delimited string that can contain one or more (but no duplications) of the following options: | <td>A blank delimited string that can contain one or more (but no duplications) of the following options. | ||
<p class="note">'''Note:''' These options are described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]. </p> | |||
<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, and if the <var>XmlDoc</var> is not empty. <var>AllowXmlDecl</var> is the default. </li> | ||
<li><b>Indent <i>n</i></b><br> | <li><b>Indent <i>n</i></b><br> | ||
Inserts space characters and line-ends into the serialized string such that if the string is broken at the line-ends and displayed as a tree, the display of each lower level in the subtree is indented ''n'' spaces from the previous level's starting point. You may also specify < | Inserts space characters and line-ends into the serialized string such that if the string is broken at the line-ends and displayed as a tree, the display of each lower level in the subtree is indented ''n'' spaces from the previous level's starting point. You may also specify <var>CR</var>, <var>LF</var>, <var>CRLF</var>, or <var>Newline</var> (see below). | ||
If <var>Indent</var> is specified and no line-end options are also specified, <var>Newline</var> is implied. | If <var>Indent</var> is specified and no line-end options are also specified, <var>Newline</var> is implied. </li> | ||
<li><b>CR</b> (carriage-return), <b>LF</b> (linefeed), <b>CRLF</b> (carriage-return followed by a linefeed), or <b>Newline</b> (line-end set for the <var class="product">Janus Web</var> connection)<br> | <li><b>CR</b> (carriage-return), <b>LF</b> (linefeed), <b>CRLF</b> (carriage-return followed by a linefeed), or <b>Newline</b> (line-end set for the <var class="product">Janus Web</var> connection)<br> | ||
Inserts one of these line-end options to provide line breaks in the serialized output. | Inserts one of these line-end options to provide line breaks in the serialized output. </li> | ||
<li><b>NoEmptyElt</b><br> | <li><b>NoEmptyElt</b><br> | ||
This deprecated option 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>). | |||
<p> | |||
<var>NoEmptyElt</var> is deprecated in order to deter users from using it to serialize HTML: The recommended approach for HTML is shown on the <var>[[NoEmptyElement (XmlNode property)#browserExample|NoEmptyElement]]</var> property page — some tags (<code><div></code>) <b>require</b> separate start and end tags, while other tags (<code><br></code>) <b>do not allow</b> separate start and end tags. </p></li> | |||
<li><b>OmitNullElement</b><br> | <li><b>OmitNullElement</b><br> | ||
An <var>Element</var> node that has no children and no <var>Attributes</var> will not be serialized, unless it is the top level <var>Element</var> in the subtree being serialized. | An <var>Element</var> node that has no children and no <var>Attributes</var> will not be serialized, unless it is the top level <var>Element</var> in the subtree being serialized. </li> | ||
<li><b>SortCanonical</b><br> | <li><b>SortCanonical</b><br> | ||
This deprecated option, serializes namespace declarations and attributes in sorted order (from lowest to highest with Unicode code ordering). It is superseded by the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method <var>ExclCanonical</var> option. | This deprecated option, serializes namespace declarations and attributes in sorted order (from lowest to highest with Unicode code ordering). It is superseded by the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method <var>ExclCanonical</var> option. </li> | ||
</ul> | </ul> | ||
</td></tr> | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The method object <var class="term">doc</var> must be [[XML processing in Janus SOAP#Well-formed documents and validation|well-formed]] (that is, it must contain an <var>Element</var> node). | <li>The method object, <var class="term">doc</var>, must be [[XML processing in Janus SOAP#Well-formed documents and validation|well-formed]] (that is, it must contain an <var>Element</var> node). | ||
<li>The output line-breaking <var class="term">options</var> make the serialized stream easier to read, for example, for a browser's "view page source" facility to display XHTML produced with <var class="product">[[Janus SOAP]]</var>. | <li>The output line-breaking <var class="term">options</var> make the serialized stream easier to read, for example, for a browser's "view page source" facility to display XHTML produced with <var class="product">[[Janus SOAP]]</var>. | ||
<li>As of <var class="product">Sirius Mods</var> Version 7.6, | <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> | ||
Line 54: | Line 63: | ||
==Request-cancellation errors== | ==Request-cancellation errors== | ||
This list is not exhaustive: it does <i>not</i> include all the errors that are request cancelling. | |||
<ul> | <ul> | ||
<li>Method object <var class="term">doc</var> does not contain an <var>Element</var>. | <li>Method object <var class="term">doc</var> does not contain an <var>Element</var>. | ||
Line 62: | Line 72: | ||
==See also== | ==See also== | ||
<ul> | <ul> | ||
<li>Use the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> function to serialize an <var>XmlDoc</var> for sending in some other fashion than as a Web response. | <li>Use the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> function to serialize an <var>XmlDoc</var> for sending in some other fashion than as a Web response. </li> | ||
<li>Additional serializing methods include: | <li>Additional serializing methods include: | ||
<ul> | <ul> | ||
<li><var>[[Print (XmlDoc/XmlNode subroutine)|Print]]</var> | <li><var>[[Print (XmlDoc/XmlNode subroutine)|Print]]</var> </li> | ||
<li><var>[[AddXml]]</var> (<var>[[HttpRequest]]</var> class) | |||
</ul> | <li><var>[[Audit (XmlDoc/XmlNode subroutine)|Audit]]</var>, <var>[[Trace (XmlDoc/XmlNode subroutine)|Trace]]</var> </li> | ||
<li>The function that receives and deserializes a Web XML request is <var>[[WebReceive (XmlDoc function)|WebReceive]]</var>. | |||
<li><var>[[AddXml (HttpRequest subroutine)|AddXml]]</var> (<var>[[HttpRequest class|HttpRequest]]</var> class) </li> | |||
</ul> </li> | |||
<li>For additional discussion about serialization, see [[XmlDoc API#Transport: receiving and sending XML|Transport: receiving and sending XML]].</li> | |||
<li>The function that receives and deserializes a Web XML request is <var>[[WebReceive (XmlDoc function)|WebReceive]]</var>. </li> | |||
</ul> | </ul> | ||
{{Template:XmlDoc:WebSend footer}} | {{Template:XmlDoc:WebSend footer}} |
Latest revision as of 21:08, 18 March 2014
Serialize XmlDoc as Web response (XmlDoc class)
WebSend converts an XmlDoc to its textually represented XML document to be sent in a response on a Janus Web Server thread. The process of converting to a text string is called serialization, because the text representation of a document is called the serial form.
The serialized output of WebSend is a UTF-8 text string. This output is added to the output buffer that is sent by a subsequent invocation of $Web_Done or $Web_Form_Done.
Syntax
doc:WebSend[( [options])]
Syntax terms
doc | An expression that points to the XmlDoc whose content is to be serialized. |
---|---|
options | A blank delimited string that can contain one or more (but no duplications) of the following options.
Note: These options are described in greater detail in "XmlDoc API serialization options".
|
Usage notes
- The method object, doc, must be well-formed (that is, it must contain an Element node).
- The output line-breaking options make the serialized stream easier to read, for example, for a browser's "view page source" facility to display XHTML produced with Janus SOAP.
- 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
The following Janus Web Server program uses WebReceive to obtain the XML document from the HTTP request, then uses WebSend to buffer some of the received data:
begin %d object xmlDoc %d = new %d:webReceive %d2 object xmlDoc %d2 = new %d2:loadXml('<sum>' with - %d:value('/*/*[1]') + %d:value('/*/*[2]') - with '</sum>') %d2:webSend end
Request-cancellation errors
This list is not exhaustive: it does not include all the errors that are request cancelling.
- Method object doc does not contain an Element.
- An options setting is invalid.
- Insufficient free space exists in CCATEMP.
See also
- Use the Serial function to serialize an XmlDoc for sending in some other fashion than as a Web response.
- Additional serializing methods include:
- Audit, Trace
- AddXml (HttpRequest class)
- For additional discussion about serialization, see Transport: receiving and sending XML.
- The function that receives and deserializes a Web XML request is WebReceive.