xmlwrite <channel>,<ident>
Creates an XML file from a structure object. Output is written to a system output channel.
<channel>
A channel identifier.
<ident>
A structure object whose values are to be written in XML.
-enc=<string>
Include an encoding attribute in the xml header. If this switch is omitted,
the encoding attribute is excluded. Typical encoding values are "UTF-8",
"windows-1252" etc. This switch is ignored if header output is suppressed.
-h
Write the xml header. This is the default behavior. By suppressing this
(-no_h) customized header can be written to the
channel instead.
The default header text is <?xml version="1.0" ?>
-pad=<num>
A padding factor to use when writing binary element values. If this switch
is present binary values will be laid out in lines of <num> characters.
The default behavior is not to format binary output but to write one long
text string.
-pre=<string>
A namespace prefix to prepend the outer root tag name. If this is omitted,
the default namespace prefix is that (if defined) of the class of the object
being processed.
-rti=<string>
Additional attribute information to be appended to the root tag statement.
If included this should be of the form: <name>="<value>"
{ ... }.
-tag=<string>
The name for the root tag in the xml output. If this switch is present then
no other attribute information is appended to the root tag, except any specific
attributes supplied via the -rti switch. If this
tag is omitted, then the default behavior is to use the tag associated with
the class of the object as the root tag, and any target namspace and schema
xsd information of the class will be included as attribute information,
together with any additional attributes specified by the -rti
switch.
Although the class of the object may have an associated xsd schema, the schema is not used during data conversion. The output characteristics of structure elements are determined by those associated with the Fire class, defined at class creation time (see the xsdread command).
Consider a simple Fire class to record details of an image:
atable test structure ~test.image_t,-tag='image' { xml attribute { string name numeric dimensions[2],-lis } blob data,-b64 }
Create an object of this class:
~test.image_t img img.name = 'dona.xpm' img.data = fileblob(img.name) img.dimensions = raspix(img.name)
The following code might be used in a Fire web service to return this data to a client in xml form:
write firerender_channel,'Content-Type: text/xml' xmlwrite firerender_channel,img,-pad=80
The output would be something like this (the -pad=80 switch would not be necessary in a production scenario):
<?xml version="1.0" ?> <image name="dona.xpm" dimensions="32 32"> <data> LyogWFBNICovCnN0YXRpYyBjaGFyICpkb25hW10gPSB7Ci8qIHdpZHRoIGhlaWdodCBuY29sb3JzIGNo YXJzX3Blcl9waXhlbCAqLwoiMzIgMzIgMTYgMSIsCi8qIGNvbG9ycyAq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ICgoIiwKIi4uLiAgLS0gICAgIyMjIyAgICAgLSAgIC0tLSAgICgoIiwKIi4uLiAtLS0gICAj IyMjIyMjICAgLS0gICAgICAgKCguIiwKIi4uLiAgICAgIyMjIyMjIyMjIyAgICAgICAgICAoKCguIiwK Ii4uICAgICAjIyMjIyMjIyMjIyMgICAgICgoKCgoLi4uIiwKIi4uICAgICMjIyMjIyMjIyMjIyMjICAg ICgoKCguLi4uIiwKIi4gICAgIyMjIyMjIyMjIyMjIyMjIyAgICAoKC4uLi4uIiwKIi4gIyMgICMjIyMj IyMjIyMjIyMjICAjICAoKC4uLi4uIiwKIi4gIyMgICAgIyMjIyMjIyMjIyAgICAjIyAoKC4uLi4uIiwK Ii4gICMjIyAgICAjIyMjIyMgICAgIyMjICAoKC4uLi4uIiwKIi4gICAjIyMgICAgICAgICAgICAjIyMg ICgoKC4uLi4uIiwKIi4uICAgIyMgICAgICAgICAgICAjIyAgKCgoLi4uLi4uIiwKIi4uLi4gICMjICAg ICoqKiAgICAjICAoKCguLi4uLi4uIiwKIi4uLi4uICAjIyAgKioqKiogICMgICgoKC4uLi4uLi4uIiwK Ii4uLi4uLiAgICMgICAgICAgIyAgKCgoLi4uLi4uLi4uIiwKIi4uLi4uLi4gICAjIyMjIyMjICAoKCgu Li4uLi4uLi4uIiwKIi4uLi4uLi4uLiAgIyMjIyMgKCgoKC4uLi4uLi4uLi4uIiwKIi4uLi4uLi4uLi4g ICAgICAoKCguLi4uLi4uLi4uLi4uIiwKIi4uLi4uLi4uLi4uLigoKCgoLi4uLi4uLi4uLi4uLi4uIiwK Ii4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uIgp9IDsK </data> </image>
You will see how the class definitions have some xml constructs (new to Fire 7.1) and element switches. These are added for xml output purposes only and have no relevance during non-xml language operations. This auxiliary information provides xml formatting and layout information. In this example base64 binary has been specified for blob output
Commands: |
|
Functions: |
|
Structures: |