WebSend (XmlDoc subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (move footer template to actual end; match syntax table to syntax template; edits, tags and links)
Line 1: Line 1:
{{Template:XmlDoc:WebSend subtitle}}
{{Template:XmlDoc:WebSend subtitle}}
<var>WebSend</var> converts an <var>XmlDoc</var> to its textually represented XML document to be sent in a response on a <var class="product">[[Janus Web Server|"Janus Web Server"]]</var> thread.  (The process of converting to a text string is called '''serialization''', because the text representation of a document is called the '''serial'''
form).


This subroutine converts an <var>XmlDoc</var> to its textually represented XML document
The serialized output of <var>WebSend</var> is a UTF-8 text string.  This output is added to the output buffer that is sent by a subsequent invocation of <var>[[$Web_Done]]</var> or <var>[[$Web_Form_Done]]</var>.
to be sent in a response on a <var class="product">[[Janus Web Server]]</var> 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 <var>WebSend</var> is a UTF-8 text string.
This output is added to the output buffer that is sent by a subsequent
invocation of <var>[[$Web_Done]]</var> or <var>[[$Web_Form_Done]]</var>.
==Syntax==
==Syntax==
{{Template:XmlDoc:WebSend syntax}}
{{Template:XmlDoc:WebSend syntax}}
Line 17: Line 12:
<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 of the following options (but no repeats), 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 (but no duplications) of the following 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>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 <code>CR</code>, <code>LF</code>, <code>CRLF</code>, or <code>Newline</code> (see below).
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 <code>CR</code>, <code>LF</code>, <code>CRLF</code>, or <code>Newline</code> (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><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><b>NoEmptyElt</b><br>
<li><b>NoEmptyElt</b><br>
Deprecated as of ''Sirius Mods'' version 7.0, this option ensures that all empty elements are serialized 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>).
Deprecated as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.0, this option ensures that all empty elements are serialized 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>
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><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).
</ul>
It is superseded by the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method <var>ExclCanonical</var> option.  
These options are described in greater detail in [[XmlDoc API serialization options|"XmlDoc API serialization options"]]</td></tr>
</ul></td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>The <var>XmlDoc</var> method object must be well-formed (that is,
<li>The method object <var class="term">Doc</var> must be well-formed (that is, it must contain an <var>Element</var> node). For more information, see [[XML processing in Janus SOAP#Well-formed documents and validation|"Well-formed documents and validation"]].
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|"Janus Soap"]]</var>.
For more information, see  
<li>As of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.6, ''Attribute values'' are always serialized within double-quotation-mark (<code>"</cod>) delimiters, and a double-quotation mark character in an attribute value is serialized as <code>&amp;quot;</code>. Prior to <var class="product">"Sirius Mods"]]</var> Version 7.6, this convention was not strictly observed.
[[XML processing in Janus SOAP#Well-formed documents and validation|"Well-formed documents and validation"]].
<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 ''Sirius Mods'' version 7.6, ''Attribute values'' are always serialized
within double-quotation-mark (<tt>"</tt>) delimiters,
and a double-quotation mark character in an attribute value is serialized
as <code>&amp;quot;</code>.
Prior to version 7.6, this convention was not strictly observed.
 
</ul>
</ul>
===Example===


The following <var class="product">[[Janus Web Server]]</var> program uses
==Examples==
WebReceive to obtain the XML document from the HTTP request,
<ol><li>The following <var class="product">[[Janus Web Server|"Janus Web Server"]]</var> program uses <var>[[WebReceive_(XmlDoc_function)|WebReceive]]</var> to obtain the XML document from the HTTP request, then uses <var>WebSend</var> to buffer some of the received data:
then uses <var>WebSend</var> to buffer some of the received data:
<p class="code">begin
<p class="code"> Begin
  %d object xmlDoc
%d Object XmlDoc
  %d = new
%d = New
  %d:[[WebReceive_(XmlDoc_function)|webReceive]]
%d:WebReceive
  %d2 object xmlDoc
%d2 Object XmlDoc
  %d2 = new
%d2 = New
  %d2:[[LoadXml_(XmlDoc/XmlNode_function)|loadXml]]('<sum>' with -
%d2:LoadXml('<sum>' With -
      %d:[[Value_(XmlDoc/XmlNode_property)|value]]('/*/*[1]') + %d:value('/*/*[2]') -
%d:Value('/*/*[1]') + %d:Value('/*/*[2]') -
      with '</sum>')
    With '</sum>')
  %d2:webSend
%d2:WebSend
end
End
</p></ol>
</p>


===Request-cancellation errors===
==Request-cancellation errors==
<ul>
<ul>
<li><var>XmlDoc</var> does not contain an <var>Element</var>.
<li><var class="term">Doc</var> does not contain an <var>Element</var>.
<li>An <var class="term">options</var> setting is invalid.
<li>An <var class="term">options</var> setting is invalid.
<li>Insufficient free space exists in CCATEMP.
<li>Insufficient free space exists in CCATEMP.
</ul>
</ul>


==See also==
==See also==
{{Template:XmlDoc:WebSend footer}}
<ul>
<ul>
<li>Use the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> function to
<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.
serialize an <var>XmlDoc</var> for sending in some other fashion than as a Web response.
<li>Additional serializing methods include:
<li>Additional serializing methods include:
<ul>
<ul>
Line 97: Line 68:
<li><var>[[AddXml]]</var> (<var>[[HttpRequest]]</var> class)
<li><var>[[AddXml]]</var> (<var>[[HttpRequest]]</var> class)
</ul>
</ul>
<li>The function that receives and deserializes a Web XML request is
<li>The function that receives and deserializes a Web XML request is <var>[[WebReceive (XmlDoc function)|WebReceive]]</var>.
<var>[[WebReceive (XmlDoc function)|WebReceive]]</var>.
</ul>
</ul>
{{Template:XmlDoc:WebSend footer}}

Revision as of 07:36, 22 May 2011

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:
  • AllowXmlDecl or NoXmlDecl
    Whether or not the serialization will contain the "XML Declaration" (<?xml version=...?>), if the value of the Version property is a non-null string, if the XmlDoc is not empty, and if the node selected by xpath is the Root node. AllowXmlDecl is the default.
  • Indent n
    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 CR, LF, CRLF, or Newline (see below). If Indent is specified and no line-end options are also specified, Newline is implied.
  • CR (carriage-return), LF (linefeed), CRLF (carriage-return followed by a linefeed), or Newline (line-end set for the Janus Web connection)
    Inserts one of these line-end options to provide line breaks in the serialized output.
  • NoEmptyElt
    Deprecated as of "Sirius Mods" Version 7.0, this option ensures that all empty elements are serialized with a start tag followed by an end tag. The default is to serialize an empty element with an empty element tag (as in <middleName/>).
  • OmitNullElement
    An Element node that has no children and no Attributes will not be serialized, unless it is the top level Element in the subtree being serialized.
  • SortCanonical
    This deprecated option, serializes namespace declarations and attributes in sorted order (from lowest to highest with Unicode code ordering). It is superseded by the Serial method ExclCanonical option.
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). For more information, see "Well-formed documents and validation".
  • 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 ("</cod>) delimiters, and a double-quotation mark character in an attribute value is serialized as &quot;. Prior to "Sirius Mods"]] Version 7.6, this convention was not strictly observed.

Examples

  1. 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

  • 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:
  • The function that receives and deserializes a Web XML request is WebReceive.