Command: xmlwrite

Syntax

xmlwrite <channel>,<ident>

Description

Creates an XML file from a structure object. Output is written to a system output channel.

Parameters

Switches

Notes

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).

Example

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
      YXJzX3Blcl9waXhlbCAqLwoiMzIgMzIgMTYgMSIsCi8qIGNvbG9ycyAqLwoiLiBjIE5vbmUiLAoiICBj
      ICMwMDAwMDAwMDAwMDAiLAoiISBjICM4MDAwMDAwMDAwMDAiLAoiIyBjICMwMDAwODAwMDAwMDAiLAoi
      JCBjICM4MDAwODAwMDAwMDAiLAoiJSBjICMwMDAwMDAwMDgwMDAiLAoiJiBjICM4MDAwMDAwMDgwMDAi
      LAoiJyBjICMwMDAwODAwMDgwMDAiLAoiKCBjICM4MDAwODAwMDgwMDAiLAoiKSBjICNjMDAwYzAwMGMw
      MDAiLAoiKiBjICNmZjAwMDAwMDAwMDAiLAoiKyBjICMwMDAwZmYwMDAwMDAiLAoiLCBjICNmZjAwZmYw
      MDAwMDAiLAoiLSBjICNmZjAwMDAwMGZmMDAiLAoiLyBjICMwMDAwZmYwMGZmMDAiLAoiMCBjICNmZjAw
      ZmYwMGZmMDAiLAovKiBwaXhlbHMgKi8KIi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uIiwK
      Ii4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uICAgICAuIiwKIi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
      Li4gIC0tLSAoIiwKIi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLiAgLS0tLSAoIiwKIi4uLi4uLi4uLi4g
      ICAgICAuLi4uLi4uICAtLS0tLSAoIiwKIi4uLi4uLi4uLiAgICAgICAgLi4uLi4gIC0tLS0tICAoIiwK
      Ii4uLi4uLi4gICAjIyMjIyMgICAuLi4gIC0tLS0gICgoIiwKIi4uLi4uLiAgICAgICAgICAgICAgLiAg
      IC0tLSAgKCAoIiwKIi4uLi4uICAgICAgLS0tLSAgICAgICAgLS0tICAoICAoIiwKIi4uLi4gICAgMDAg
      LS0tLSAwMCAgICAtLSAgICAgLSAoIiwKIi4uLiAgIC0gMCAgLS0tLSAgMCAgICAgICAgICAtICAoIiwK
      Ii4uLiAgLS0gMCAgLS0tLSAgMCAgLSAtICAgLS0tICgoIiwKIi4uLiAgIC0gMCAgICAgICAgMCAgLSAg
      IC0tLS0gICgoIiwKIi4uLiAgLS0gICAgIyMjIyAgICAgLSAgIC0tLSAgICgoIiwKIi4uLiAtLS0gICAj
      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

See Also

Commands:

structure, sysdump xsd, xmlread, xsdread, xsdwrite

Functions:

xmlclass (string), xmltest (string)

Structures:

.xml_tag, .xml_*