Defining and Using Classes
Defining and Using XData Blocks
An XData block
is a class member that consists of a name and a unit of well-formed XML that you include in a class definition for use by the class after compilation. This chapter discusses XData blocks and covers the following topics:
When viewing this book online, use the preface
of this book to quickly find related topics.
An XData block
is a named unit of well-formed XML that you include in a class definition. The purpose of this block is to contain structured information for some particular purpose for use by the class after compilation.
You can create an XData block by typing it directly in Atelier.
An XData block is a named class member (like properties, methods, and so on). The available XData block keywords include:
Optionally specifies an XML schema against which the XData can be validated.
Optionally specifies the XML namespace to which the XData block belongs. You can also, of course, include namespace declarations within the XData block itself.
The contents of the XData block must consist of one root XML element, with any valid contents.
An XData block is useful if you want to define a small amount of system data. For example, suppose that the EPI.AllergySeverity
class includes the properties Code
(for internal use) and Description
(for display to the users). This class could include an XData block like the following:
<row>99^Unable to determine</row>
The same class could also include a class method that reads this XData block and populates the table, as follows:
/// called by EPI.Utils.GenerateData
ClassMethod Setup() As %Status
//first kill extent
// Get a stream of XML from the XData block contained in this class
If '$IsObject(tStream) Set tSC=%objlasterror Quit
if $$$ISERR(status) do $System.Status.DisplayError(status) quit
//iterate through document, node by node
The XML within the XData is minimal. That it, instead of presenting the allergy severities as XML element with their own elements or attributes, the XData block simply presents rows of data as delimited strings. This approach allows you to write the setup data in a visually compact form.