%XML.Schema
class %XML.Schema extends %Library.RegisteredObject
The %XML.Schema 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 AddSchemaType() method. The schema is build up in an XML DOM by AddSchemaType() and may later be output using %XML.Writer. The DocumentNode() or Tree() methods of the %XML.Writer class can be used to output the schema.XML namespace handling is for the most part automatic. %XML.Schema 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))
// 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()) }
Property Inventory
Method Inventory
Properties
property AllowRedundantArrayName as %Boolean;
If AllowRedundantArrayName 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.
If - =
, then is not appended unless AllowRedundantArrayName is true.
The normal format of an array name for an Array is ArrayOf- PairOf
.
If =, then is not appended unless AllowRedundantArrayName is true.
The normal format of an array name for a List is ArrayOf
The normal format of an array name for an Array is ArrayOf
Property methods: AllowRedundantArrayNameDisplayToLogical(), AllowRedundantArrayNameGet(), AllowRedundantArrayNameIsValid(), AllowRedundantArrayNameLogicalToDisplay(), AllowRedundantArrayNameNormalize(), AllowRedundantArrayNameSet()
property DefaultNamespace as %String;
DefaultNamespace 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.
Property methods: DefaultNamespaceDisplayToLogical(), DefaultNamespaceGet(), DefaultNamespaceIsValid(), DefaultNamespaceLogicalToDisplay(), DefaultNamespaceLogicalToOdbc(), DefaultNamespaceNormalize(), DefaultNamespaceSet()
property IncludeDocumentation as %Boolean [ InitialExpression = 1 ];
If IncludeDocumentation is true, then the class and property
comments are included in the schema as elements.
The default is to include the documentation.
Property methods: IncludeDocumentationDisplayToLogical(), IncludeDocumentationGet(), IncludeDocumentationIsValid(), IncludeDocumentationLogicalToDisplay(), IncludeDocumentationNormalize(), IncludeDocumentationSet()
property Namespaces as %ListOfDataTypes;
List of referenced namespaces
Namespaces = count of namespaces defined
Namespaces(namespaceIndex)=namespace
Property methods: NamespacesGet(), NamespacesGetObject(), NamespacesGetObjectId(), NamespacesGetSwizzled(), NamespacesIsEmpty(), NamespacesIsValid(), NamespacesNewObject(), NamespacesSet(), NamespacesSetObject(), NamespacesSetObjectId(), NamespacesUnSwizzle()
Methods
method %OnClose() as %Status
Inherited description: This callback method is invoked by the %Close() method to
provide notification that the current object is being closed.
The return value of this method is ignored.
Initialize schema index and schema document on constuction of object,
rootName is the name used for the dummy root element
in the schema document.
method AddSchemaType(class As %String, top As %String = "", format As %String, summary As %Boolean = 0, input As %Boolean = 0, refOnly As %Boolean = 0) as %Status
Add a complexType to the schema.
class is the name of the class which corresponds to the complexType.
top is the optional override of the type name.
format 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 format is "" which currently is the same as the "literal" formatting, but may be a unique encoding in the future.
top is the optional override of the type name.
format 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 format is "" which currently is the same as the "literal" formatting, but may be a unique encoding in the future.
summary=true if summary type is to be created.
input=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
input=false. Normally, this argument is not relevant since the all properties
of a class participate in input and output.
refOnly=true means that only the portions of the schema for
referenced types are generated. The schema for this class is not generated.
Default is refOnly=false that generates the entire schema.
method DefineExtraImports(namespace As %String, ByRef imports)
Define any additional import elements for a schema
The imports array is of the form imports(namespace)=location
Define the location for import elements for a schema
Get the node for the schema element that corresponds to the specified namespace.
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()