Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions pageOpens in a new window (login required).

Introduction to Object-XML Projections

This book describes how to project Caché objects to XML and how to control that projection to XML elements, attributes, and types.

This topic introduces how to project objects to XML and explains why you might want to do this.

For information on XML standards supported in Caché, see “Standards Supported by Caché” in Using Caché XML Tools.

The Basics

The phrase projecting an object to XML means defining how that object can be used as an XML document. To project an object to XML, you add %XML.AdaptorOpens in a new window to the superclass list of the class that defines the object, as well as any other object classes used by that class, with minor exceptions.

This activity is also called defining the XML projection of the class that defines the object or XML-enabling that class.

How It Works

When you define the XML projection for a class:

  • The system generates additional INT code for the class that enables you to use class instances as XML documents. (This code is generated when you compile the class, and you should not edit it.)

  • Each property of your class automatically inherits from %XML.PropertyParametersOpens in a new window.

  • %XML.AdaptorOpens in a new window adds XML-related class parameters to your class.

  • %XML.PropertyParametersOpens in a new window adds XML-related property parameters to properties in your class.

  • Data type properties define the LogicalToXSD() and XSDToLogical() methods, which control how data is transformed when output to XML or input from XML.

Then, if the default projection is not suitable for your needs, you edit the XML-related parameters in your class as needed.

Projection Options

The XML projection for a given class determines how instances of that class correspond to XML documents and vice versa. For example:

generated description: xmlobj

You can control the XML projection in many ways, including the following:

  • Controlling the structure to which a property is projected. For example, simple properties can be projected as either elements or attributes — or they cannot be projected at all, as shown in the preceding example.

  • Controlling the XML element and attribute names.

  • Controlling the XML namespaces to which elements and attributes are assigned.

  • Controlling the details of how the Caché class is mapped to an XML schema.

With noted exceptions, these parameters affect all the scenarios in which you use the XML-enabled class.

Possible Applications for XML Documents

You can use XML documents in a variety of practical applications, including:

  • As a standard format in messaging applications. This includes industry-standard protocols as well as homegrown solutions.

  • As a standard format for data exchange between applications and users.

  • As a standard representation for external data storage. This may include traditional database records or it may include more complex content such as documentation.

  • As the payload of SOAP messages sent between web services and web clients.

  • As the contents of an XData block in a class definition. See “XData Blocks” in Using Caché Objects.

FeedbackOpens in a new window