WebSend (XmlDoc subroutine): Difference between revisions
m 1 revision |
m 1 revision |
||
| Line 5: | Line 5: | ||
<!--DPL?? Category:XmlDoc API methods|WebSend (XmlDoc subroutine): Serialize XmlDoc as Web response--> | <!--DPL?? Category:XmlDoc API methods|WebSend (XmlDoc subroutine): Serialize XmlDoc as Web response--> | ||
<!--DPL?? Category:System methods|WebSend (XmlDoc subroutine): Serialize XmlDoc as Web response--> | <!--DPL?? Category:System methods|WebSend (XmlDoc subroutine): Serialize XmlDoc as Web response--> | ||
This subroutine converts an XmlDoc to its textually represented XML document | This subroutine converts an XmlDoc to its textually represented XML document | ||
Revision as of 05:33, 25 January 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 about well-formed documents, see ?? refid=welform..
- 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 version 6.7, the WebSend method uses the hexadecimal
character references specified in the XML Canonicalization specification
(:hp0 color=SirLink.http://www.w3.org/TR/xml-c14n:ehp0.) to
display the following characters:
- For Attribute nodes: tab, carriage return, and linefeed
- For Text nodes: carriage return
Since the character references are not subject to the standard XML whitespace normalization (?? refid=normwhi.), a serialized document (or subtree) that is then deserialized will retain this whitespace.
These character references are used:
- tab
- 	
- CR
- 
- LF
- 

The EBCDIC and corresponding ASCII encodings of the characters is:
- &thinsp.
- EBCDIC ASCII
- tab
- X'05' X'09'
- CR
- X'0D' X'0D'
- LF
- X'25' X'0A'
- 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.
- options 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, described in the Janus SocketsR.)
- The function that receives and deserializes a Web XML request is ??WebReceive.