XML is fast becoming the standard format for passing structured data around the internet, and much general purpose software has been written for tasks such as the parsing, editing, display and transformation of XML data. The XmlChan class (a specialised form of Channel) provides facilities for storing AST objects externally in the form of XML documents, thus allowing such software to be used.
The primary XML format used by the XmlChan class is a fairly close transliteration of the AST native format produced by the basic Channel class. Currently, there is no DTD or schema defining the structure of data produced in this format by an XmlChan. The following is a native AST representation of a simple 1-D Frame (including comments and with the Full attribute set to zero so that some default attribute values are included as extra comments):
Begin Frame # Coordinate system description # Title = "1-d coordinate system" # Title of coordinate system Naxes = 1 # Number of coordinate axes Domain = "SCREEN" # Coordinate system domain # Lbl1 = "Axis 1" # Label for axis 1 # Uni1 = "cm" # Units for axis 1 Ax1 = # Axis number 1 Begin Axis # Coordinate axis Unit = "cm" # Axis units End Axis End Frame
The corresponding XmlChan output would look like:
<Frame xmlns="http://www.starlink.ac.uk/ast/xml/" desc="Coordinate system description"> <_attribute name="Title" quoted="true" value="1-d coordinate system" desc="Title of coordinate system" default="true"/> <_attribute name="Naxes" value="1" desc="Number of coordinate axes"/> <_attribute name="Domain" quoted="true" value="SCREEN" desc="Coordinate system domain"/> <_attribute name="Lbl1" quoted="true" value="Axis 1" desc="Label for axis 1" default="true"/> <_attribute name="Uni1" quoted="true" value="cm" desc="Units for axis 1" default="true"/> <Axis label="Ax1" desc="Coordinate axis"> <!--Axis number 1--> <_attribute name="Unit" quoted="true" value="cm" desc="Axis units"/> </Axis> </Frame>
Notes:
http://www.starlink.ac.uk/ast/xml/
which will be
inherited by all nested elements.
The XmlChan class changes the default value for the Comment and Full attributes (inherited from the base Channel class) to zero and -1, resulting in terse output by default. With the default values for these attributes, the above XML is reduced to the following:
<Frame xmlns="http://www.starlink.ac.uk/ast/xml/"> <_attribute name="Naxes" value="1"/> <_attribute name="Domain" quoted="true" value="SCREEN"/> <Axis label="Ax1"> <_attribute name="Unit" quoted="true" value="cm"/> </Axis> </Frame>
The XmlChan class uses the Skip attributes very similarly to the Channel
class. If Skip is zero (the default) then an error will be reported if the text
supplied by the source function does not begin with an AST Object. If
Skip is non-zero, then initial text is skipped over without error until
the start of an AST object is found. this allows an AST object to be
located within a larger XML document.
AST A Library for Handling World Coordinate Systems in Astronomy