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
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.
||An expression that points to the XmlDoc whose content is to be serialized. |
||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":
- 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
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.
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
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.
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.
- 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
Prior to version 7.6, this convention was not strictly observed.
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:
%d Object XmlDoc
%d = New
%d2 Object XmlDoc
%d2 = New
%d2:LoadXml('<sum>' With -
%d:Value('/*/*') + %d:Value('/*/*') -
- XmlDoc does not contain an Element.
- An options setting is invalid.
- Insufficient free space exists in CCATEMP.
- 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