Command: xsdwrite

Syntax

xsdwrite <channel>,<ident>

Description

Creates an XSD file from a Fire class structure. Output is written to a system output channel.

Parameters

Switches

Notes

The output of this command is simplistic (by xml standards) and its use is primarily for creating a rough cut of an xsd schema from a Fire class.

This command is not the reverse of the xsdread command since there are many xml concepts which have no parallel within the system. It is intended merely to be a utility command for those unfamiliar with the intricacies of xsd schemas.

Default and fixed values are not included in the output although other xml output characteristics attached to the Fire class structure members will be used where possible. Most Fire member types are mapped to xml string types.

Typically, post creation, the xsd schema file would be manually edited to set any array limits, value constraints and input/output rules for which there are no Fire equivalents.

Example

Consider a (totally fictional) Fire structure, containing a sub-structure element:

atable test
structure ~test.subthing_t {
   time t,-tdo;         # Date only i/o
   window w
}
structure ~test.thing_t {
   xml attribute {
      numeric xvalue
      string name
      string option[];  # Optional attribute
   }
   string svalue
   string tokens[],-lis;# List of values
   numeric nvalue,-int; # Integer value
   blob image,-hex;     # Hexadecimal binary i/o
   ~test.subthing_t subs[]
}

The commands to create an xsd schema file from this structure might be as follows:

open ch,-of=thing.xsd
xsdwrite ch,~test.thing_t,-tag='thing',-pre='acme',-ns="http://www.acme.net/"
ch.close

The resulting xsd file would be like this:

<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:acme="http://www.acme.net/"
      targetNamespace="http://www.acme.net/"
      elementFormDefault="unqualified" attributeFormDefault="unqualified">
   <xsd:element name="thing" type="acme:thing_t" />
   <xsd:simpleType name="stringList">
      <xsd:list itemType="xsd:string" />
   </xsd:simpleType>
   <xsd:complexType name="subthing_t">
      <xsd:sequence>
         <xsd:element name="t" type="xsd:date" />
         <xsd:element name="w" type="xsd:token" />
      </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="thing_t">
      <xsd:sequence>
         <xsd:element name="svalue" type="xsd:string" />
         <xsd:element name="tokens" type="acme:stringList" minOccurs="0" />
         <xsd:element name="nvalue" type="xsd:int" />
         <xsd:element name="image" type="xsd:hexBinary" />
         <xsd:element name="subs" type="acme:subthing_t" minOccurs="0" maxOccurs="unbounded" />
      </xsd:sequence>
      <xsd:attribute name="xvalue" type="xsd:decimal" use="required" />
      <xsd:attribute name="name" type="xsd:string" use="required" />
      <xsd:attribute name="option" type="xsd:string" />
   </xsd:complexType>
</xsd:schema>

You will see how the class definitions have some xml constructs (new to Fire 7.1) and element switches. These are added for xml input/output purposes only and have no relevance during non-xml language operations. When objects of a particular class are read by the xmlread command, or written by the xmlwrite command, this auxiliary information provides xml formatting and layout information.

When an xsdread command is used to create Fire classes (the reverse of this command), such constructs and switches are added automatically to Fire class creation statements.

As mentioned in Notes above, Fire classes created by an xsdread command will not necessarily produce a fully functional xml schema when processed by an xsdwrite command. However the output from an xsdwrite command should always re-create the correct Fire structures when subseqeuently read by an xsdread command.

See Also

Commands:

structure, sysdump xsd, xmlread, xmlwrite, xsdread

Functions:

xmlclass (string), xmltest (string)

Structures:

.xml_tag, .xml_*