5.36.5 WRITE
The WRITE command is used to create and write out XML components.
The OBJECT keyword specifies the type of XML component to create.
Syntax:
Command
|
Keyword
|
Value
|
Developer notes
|
WRITE
|
OBJECT
|
*DOCUMENTSTART
|
Start of XML document.
|
*DOCTYPE
|
Include TEXT.
|
*COMMENT
|
Include TEXT.
|
*INSTRUCTION
|
Include TARGET + DATA.
|
*NAMESPACE
|
Inlcude PREFIX + NAMESPACE.
|
*ELEMENTSTART
|
Start of element.
|
*TEXT
|
Include TEXT.
|
*CDATA
|
Include TEXT.
|
*ELEMENTEND
|
End of element.
|
*ELEMENTEMPTY
|
Include NAME.
|
*DOCUMENTEND
|
End of XML document.
|
NAME
|
qualified name
|
Optional. The qualified XML element name.
This keyword is used with the following OBJECT types.
- *ELEMENTSTART
- *ELEMENTEMPTY
The notation for expressing a qualified element name as a string is to enclose the namespace URI inside curly brackets and prefix the element name with this namespace.
For example: {http://www.cars.com/xml}part
Element attributes can be created by using a two-field working list that contains qualified attribute name and values as an argument to the WRITE OBJECT(*ELEMENTSTART) command.
|
PREFIX
|
prefix
|
Optional. Specify an XML prefix. Only used with the OBJECT type of *NAMESPACE.
|
NAMESPACE
|
namespace
|
Optional. Specify an XML namespace. Only used with the OBJECT type of *NAMESPACE.
|
TEXT
|
text
|
Optional. Specify the text value. Used with the following OBJECT types.
- *DOCTYPE
- *COMMENT
- *TEXT
- *CDATA
|
TARGET
|
target
|
Optional. Specify the processing instruction target. Only used with the OBJECT type of *INSTRUCTION.
|
DATA
|
data
|
Optional. Specify the processing instruction data. Only used with the OBJECT type of *INSTRUCTION.
|
|
Example
OPEN FILE(order.xml)
WRITE OBJECT(*DOCUMENTSTART)
WRITE OBJECT(*DOCTYPE) TEXT(<!DOCTYPE Orders SYSTEM "order.dtd">)
WRITE OBJECT(*COMMENT) TEXT(Some comment text)
WRITE OBJECT(*INSTRUCTION) TARGET(action) DATA(reply)
SET OBJECT(*PREFIX) PREFIX(abc) NAMESPACE(http://salesorder.com)
SET OBJECT(*DEFAULTNS) NAMESPACE(http://parts.com)
WRITE OBJECT(*ELEMENTSTART) NAME({http://acme.com}Orders) #WRKLST(attribute list)
WRITE OBJECT(*TEXT) TEXT(Some text)
WRITE OBJECT(*ELEMENTEND)
WRITE OBJECT(*ELEMENTEMPTY) NAME({http://acmme.com}SalesOrder)
WRITE OBJECT(*ELEMENTSTART) NAME({http://acme.com}Address)
WRITE OBJECT(*CDATA) TEXT(Some text)
WRITE OBJECT(*NAMESPACE) PREFIX(def) NAMESPACE(http://acme2.com)
WRITE OBJECT(*ELEMENTEND)
WRITE OBJECT(*DOCUMENTEND)
CLOSE