WebSend (XmlDoc subroutine): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 46: | Line 46: | ||
</p> | </p> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The | <li>The <var>XmlDoc</var> method object must be well-formed (that is, | ||
it must contain an Element node). | it must contain an <var>Element</var> node). | ||
For more information | For more information, see | ||
<li>The output line-breaking | [[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 | 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 [[Janus SOAP]]. | ||
<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, | ||
and a double-quotation mark character in an attribute value is serialized | and a double-quotation mark character in an attribute value is serialized | ||
as < | as <code>&quot;</code>. | ||
Prior to version 7.6, this convention was not strictly observed. | Prior to version 7.6, this convention was not strictly observed. | ||
Line 102: | Line 69: | ||
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: | ||
<p class="code">Begin | <p class="code"> Begin | ||
%d Object XmlDoc | %d Object XmlDoc | ||
%d = New | %d = New | ||
%d:WebReceive | %d:WebReceive | ||
%d2 Object XmlDoc | %d2 Object XmlDoc | ||
%d2 = New | %d2 = New | ||
%d2:LoadXml('<sum>' With - | %d2:LoadXml('<sum>' With - | ||
%d:Value('/*/*[1]') + %d:Value('/*/*[2]') - | %d:Value('/*/*[1]') + %d:Value('/*/*[2]') - | ||
With '</sum>') | |||
%d2:WebSend | %d2:WebSend | ||
End | End | ||
</p> | </p> | ||
===Request- | ===Request-cancellation errors=== | ||
<ul> | <ul> | ||
<li><var>XmlDoc</var> does not contain an Element. | <li><var>XmlDoc</var> does not contain an <var>Element</var>. | ||
<li>< | <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> | ||
Line 132: | Line 99: | ||
<ul> | <ul> | ||
<li>[[Print (XmlDoc/XmlNode subroutine)|Print]] | <li>[[Print (XmlDoc/XmlNode subroutine)|Print]] | ||
<li>AddXml ( | <li>[[AddXml]] ([[HttpRequest]] 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]]. | |||
</ul> | </ul> |
Revision as of 01:50, 16 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 | Any combination of the following options (but single occurrences only):
|
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.