WebSend (XmlDoc subroutine): Difference between revisions
m (→Syntax terms) |
mNo edit summary |
||
Line 2: | Line 2: | ||
This subroutine converts an <var>XmlDoc</var> to its textually represented XML document | This subroutine converts an <var>XmlDoc</var> to its textually represented XML document | ||
to be sent in a response on a [[Janus Web Server]] thread. | 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''', | (The process of converting to a text string is called '''serialization''', | ||
because the text representation of a document is called the '''serial''' | because the text representation of a document is called the '''serial''' | ||
Line 9: | Line 9: | ||
The serialized output of <var>WebSend</var> is a UTF-8 text string. | 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 | This output is added to the output buffer that is sent by a subsequent | ||
invocation of [[$Web_done]] or [[$Web_form_done]]. | invocation of <var>[[$Web_done]]</var> or <var>[[$Web_form_done]]</var>. | ||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc:WebSend syntax}} | {{Template:XmlDoc:WebSend syntax}} | ||
Line 20: | Line 20: | ||
<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 [[Version (XmlDoc property)|Version]] 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. | ||
Line 39: | Line 39: | ||
This deprecated option serializes namespace declarations and attributes in sorted order (from lowest to highest with Unicode code ordering). | 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 (XmlDoc/XmlNode function)|Serial]] method <var>ExclCanonical</var> option. | It is superseded by the <var>[[Serial (XmlDoc/XmlNode function)|Serial]]</var> method <var>ExclCanonical</var> option. | ||
</ul></td></tr> | </ul></td></tr> | ||
</table> | </table> | ||
Line 52: | Line 52: | ||
<li>The output line-breaking <var class="term">options</var> make the serialized stream | <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 | easier to read, for example, for a browser's "view page source" facility | ||
to display XHTML produced with [[Janus SOAP]]. | to display XHTML produced with <var class="product">[[Janus SOAP]]</var>. | ||
<li>As of ''Sirius Mods'' version 7.6, ''Attribute values'' are always serialized | <li>As of ''Sirius Mods'' version 7.6, ''Attribute values'' are always serialized | ||
within double-quotation-mark (<tt>"</tt>) delimiters, | within double-quotation-mark (<tt>"</tt>) delimiters, | ||
Line 62: | Line 62: | ||
===Example=== | ===Example=== | ||
The following [[Janus Web Server]] program uses | The following <var class="product">[[Janus Web Server]]</var> program uses | ||
WebReceive to obtain the XML document from the HTTP request, | WebReceive 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: | ||
Line 90: | Line 90: | ||
<ul> | <ul> | ||
<li>Use the [[Serial (XmlDoc/XmlNode function)|Serial]] 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> | ||
<li>[[Print (XmlDoc/XmlNode subroutine)|Print]] | <li><var>[[Print (XmlDoc/XmlNode subroutine)|Print]]</var> | ||
<li>[[AddXml]] ([[HttpRequest]] 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 | ||
[[WebReceive (XmlDoc function)|WebReceive]]. | <var>[[WebReceive (XmlDoc function)|WebReceive]]</var>. | ||
</ul> | </ul> |
Revision as of 16:05, 17 February 2011
Serialize XmlDoc as Web response (XmlDoc class)
This subroutine 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 of the following options (but no repeats), which are identified below and described in greater detail in "XmlDoc API serialization options":
|
Usage notes
- The XmlDoc method object 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 (") delimiters,
and a double-quotation mark character in an attribute value is serialized
as
"
. Prior to version 7.6, this convention was not strictly observed.
Example
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
- XmlDoc 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:
- AddXml (HttpRequest class)
- The function that receives and deserializes a Web XML request is WebReceive.