IRISLIB database
Schema Class Reference

The <class>XML.Schema</class> controls creation of an XML Schema from InterSystems IRIS. More...

Inheritance diagram for Schema:
Collaboration diagram for Schema:

Public Member Functions

_.Library.Status AddSchemaType (_.Library.String class, _.Library.String top, _.Library.String format, _.Library.Boolean summary, _.Library.Boolean input, _.Library.Boolean refOnly)
 Add a complexType to the schema. More...
 
 DefineExtraImports (_.Library.String namespace, imports)
 Define any additional import elements for a schema. More...
 
 DefineLocation (_.Library.String namespace, _.Library.String location)
 Define the location for import elements for a schema.
 
_.XML.Node GetSchema (_.Library.String namespace)
 Get the node for the schema element that corresponds to the specified namespace.
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 

Public Attributes

 AllowRedundantArrayName
 If <property>AllowRedundantArrayName</property> is true, then an array name that is used for an ObjectScript list. More...
 
 DefaultNamespace
 <property>DefaultNamespace</property> is the XML namespace to use More...
 
 IncludeDocumentation
 If <property>IncludeDocumentation</property> is true, then the class and property. More...
 
 Namespaces
 List of referenced namespaces. More...
 

Private Member Functions

_.Library.Status OnClose ()
 This callback method is invoked by the <METHOD>Close</METHOD> method to. More...
 
_.Library.Status OnNew (_.Library.String rootName)
 Initialize schema index and schema document on constuction of object,. More...
 

Additional Inherited Members

- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 

Detailed Description

The <class>XML.Schema</class> controls creation of an XML Schema from InterSystems IRIS.

It generates a complete XML document that contains the schema including the <?xml> tag. XML types are added to the schema by using the <method>AddSchemaType</method> method. The schema is build up in an XML DOM by <method>AddSchemaType</method> and may later be output using XML.Writer. The <method>DocumentNode</method> or <method>Tree</method> methods of the <class>XML.Writer</class> class can be used to output the schema.

XML namespace handling is for the most part automatic.
<class>XML.Schema</class> adds namespaces for which XML.Writer then automatically creates prefixes for the XML output as needed. The XML namespaces for which schemas are created are listed in the Namespaces property which is a list of strings. The GetSchema method is used to get the XML DOM node for a namespace's schema.

The following example can be executed in the SAMPLES namespace.

; Get XML.Schema instance. set schema=##class(XML.Schema).New() set namespace="http://tempuri.org/ISC/Samples" set schema.DefaultNamespace=namespace ; Get XML.Writer instance. set writer=##class(XML.Writer).New() set writer.Indent=1 do writer.AddSchemaNamespace() do writer.AddNamespace(namespace,"sample") ; Add Company. Note that referenced types are also added. set status=schema.AddSchemaType("Sample.Company") if $system.Status.IsError(status) do $system.Status.DisplayError(status) quit ; Add Vendor. set status=schema.AddSchemaType("Sample.Vendor") if $system.Status.IsError(status) do $system.Status.DisplayError(status) quit ; Verify that we have just our expected namespace. ; This is included for just for illustration. if (schema.Namespaces.Count()'=1) || (schema.Namespaces.GetAt(1)'=namespace) { write !,"Unexpected namespace found",! write !,"List Of Namespace: ",! for i=1:1:schema.Namespaces.Count() { write " ",schema.Namespaces.GetAt(i),! } write ! quit } ; Output the schema. set status=writer.DocumentNode(schema.GetSchema(namespace))

XML.Schema automatically adds import elements to the generated schema. It is the responsibility of the user code to use the DefineLocation method to define the schemaLocation. See the following example of use DefineLocation for multiple namespaces:

// className is the name of a class which references classes defined in // multiple namespaces. For example: className="test.A" in namespace "urn:testA", // test.A references test.B (in namespace "urn:testB") and test.C (in namespace "urn:testC"). try { #; get a schema writer set schemaWriter = ##class(XML.Schema).New() set sc = schemaWriter.AddSchemaType(className) if ($$$ISOK(sc)) { set namespaces = schemaWriter.Namespaces for i=1:1:namespaces.Count() { set ns=namespaces.GetAt(i) // set file path according to application dependent formula set locations(ns)="c:\temp\"_$piece(ns,":",2)_".xml" do schemaWriter.DefineLocation(ns,locations(ns)) } for i=1:1:namespaces.Count() { set ns=namespaces.GetAt(i) set schema = schemaWriter.GetSchema(ns) set writer = ##class(XML.Writer).New() do writer.OutputToFile(locations(ns)) set writer.Indent = 1 set sc=writer.DocumentNode(schema) If $$$ISERR(sc) do $system.OBJ.DisplayError(sc) Quit do writer.Reset() } } else { do $system.OBJ.DisplayError(sc) } } catch(tException) { do $system.OBJ.DisplayError(tException.AsStatus()) }

Member Function Documentation

◆ OnClose()

_.Library.Status OnClose ( )
private

This callback method is invoked by the <METHOD>Close</METHOD> method to.

provide notification that the current object is being closed.

The return value of this method is ignored.

Reimplemented from RegisteredObject.

◆ OnNew()

_.Library.Status OnNew ( _.Library.String  rootName)
private

Initialize schema index and schema document on constuction of object,.

<property>rootName</property> is the name used for the dummy root element in the schema document.

◆ AddSchemaType()

_.Library.Status AddSchemaType ( _.Library.String  class,
_.Library.String  top,
_.Library.String  format,
_.Library.Boolean  summary,
_.Library.Boolean  input,
_.Library.Boolean  refOnly 
)

Add a complexType to the schema.

<var>class</var> is the name of the class which corresponds to the complexType.<br>

<var>top</var> is the optional override of the type name.<br>

<var>format</var> is the parameter formatting type ("literal", "encoded" or "encoded12") to
be used for this object.  In addition, the value "element" is the same as
"literal" formatting with an element at the top level.  The default value for <var>format</var> is "" 
which currently is the same as the "literal" formatting, but may be a 
unique encoding in the future.<p>

<var>summary</var>=true if summary type is to be created.

<var>input</var>=true means that the schema for the input XML will be generated, 
otherwise the schema for the output XML will be generated.  The default is 
<var>input</var>=false.  Normally, this argument is not relevant since the all properties
of a class participate in input and output.<br>

<var>refOnly</var>=true means that only the portions of the schema for
referenced types are generated.  The schema for this class is not generated.
Default is <var>refOnly</var>=false that generates the entire schema.<br>

◆ DefineExtraImports()

DefineExtraImports ( _.Library.String  namespace,
  imports 
)

Define any additional import elements for a schema.

The imports array is of the form imports(namespace)=location

Member Data Documentation

◆ AllowRedundantArrayName

AllowRedundantArrayName

If <property>AllowRedundantArrayName</property> is true, then an array name that is used for an ObjectScript list.

or a pair type name that is used for an ObjectScript array will be allowed to have a type name = to the item name.

The normal format of an array name for a List is ArrayOf<item name><type name>. If =<type name>, then <type name> is not appended unless AllowRedundantArrayName is true.

The normal format of an array name for an Array is ArrayOf<item name>PairOf<key name><type name>. If <key name>=<type name>, then <type name> is not appended unless AllowRedundantArrayName is true.  

◆ DefaultNamespace

DefaultNamespace

<property>DefaultNamespace</property> is the XML namespace to use

for any classes that do not have the NAMESPACE parameter specified. If the NAMESPACE parameter is specified for a class, then the namespace specified in the class is always used.  

◆ IncludeDocumentation

IncludeDocumentation

If <property>IncludeDocumentation</property> is true, then the class and property.

comments are included in the schema as <xs:documentation> elements. The default is to include the documentation.  

◆ Namespaces

List of referenced namespaces.

Namespaces = count of namespaces defined Namespaces(namespaceIndex)=namespace