Skip to main content

Using the XML Schema Wizard

Important:

InterSystems® Studio has been deprecatedOpens in a new tab. Beginning with version 2024.2, it is no longer included with installations of InterSystems IRIS®, and it is no longer receiving maintenance updates. An upgrade to InterSystems IRIS 2024.2 or later will remove any Studio installation which is associated with the instance.

The version of InterSystems Studio which was included with InterSystems IRIS 2024.1 is available as a stand-alone component from the WRC Downloads page (https://wrc.intersystems.com/wrc/coDistGen.cspOpens in a new tab). To show only the Studio downloads, type studio in the Name column. Neither upgrades nor new installations of InterSystems IRIS will affect a stand-alone Studio installation.

InterSystems provides the following documentation about Studio 2024.1 for legacy support only. InterSystems recommends that all users develop ObjectScript code using the InterSystems ObjectScript Extension Pack for Visual Studio Code. See Migrate from Studio.

Studio provides a wizard that you can use to generate XML-enabled classes from an XML schema.

Using the Wizard

To use the XML Schema Wizard:

  1. Select Tools > Add-Ins > XML Schema Wizard.

  2. On the first screen, you specify the XML schema to use. Do one of the following:

    • For Schema File, select Browse to select an XML schema file.

    • For URL, specify the URL of the schema.

  3. Select Next.

    The next screen displays the schema so that you can verify that you have chosen the correct one.

  4. Optionally select the following options:

    • Keep Empty Classes, which specifies whether to keep unused classes that have no properties. If you select this option, such classes are not removed at the end of the wizard; otherwise, they are removed.

    • Create No Array Properties, which controls whether the wizard generates array properties. If you select this option, the wizard does not generate array properties but instead generates another form.

    • Generate XMLNIL property parameter for nillable elements, which controls whether the wizard specifies the XMLNIL property parameter for applicable properties in the generated classes.

      This option applies to each property that corresponds to an XML element that is specified with nillable="true". If you select this option, the wizard adds XMLNIL=1 to the property definition. Otherwise, it does not add this parameter.

    • Generate XMLNILNOOBJECT property parameter for nillable elements, which controls whether the wizard specifies the XMLNILNOOBJECT property parameter for applicable properties in the generated classes.

      This option applies to each property that corresponds to an XML element that is specified with nillable="true". If you select this option, the wizard adds XMLNILNOOBJECT=1 to the property definition. Otherwise, it does not add this parameter.

  5. Select Next.

    The next screen displays some basic information on options about the classes to generate.

  6. On this screen, specify the following options:

    • Optionally select Compile generated classes if you want the wizard to compile the generated classes.

    • Optionally select Add NAMESPACE Class Parameter to specify the NAMESPACE parameter. In this case, NAMESPACE is set to the value of the targetNamespace in the schema.

      If you leave this option clear, NAMESPACE is not specified.

      It is recommended to select this option in all cases, because every XML-enabled class should be assigned to an XML namespace. (For backward compatibility, however, it is possible to leave this option clear.)

    • If you want the generated classes to be persistent classes, select Create Persistent Classes. Then the classes extend %Persistent.

      You can change this later in the wizard for individual classes.

    • If you generate persistent classes, you have options to determine how to handle a <complexType> A that consists of a <sequence> of another <complexType> B. When the wizard generates a persistent class containing property A, there are three possible forms for this property. It can be defined as a list of objects, as a one-to-many relationship (the default), or as a parent-child relationship. The options are summarized in the following table:

      Use Relationships for Collection Properties in Persistent Classes Add index to many-one relationship Use parent-child relationship Form of the generated property A
      selected (default) not selected not selected One-to-many relationship with no index
      selected (default) selected not selected One-to-many relationship with index on the many side
      selected (default) This option is ignored if you select Use parent-child relationship selected Parent-child relationship
      not selected not selected not selected List of objects

      Also, if Use parent-child relationship is not selected, optionally select the option Add %OnDelete method to classes in order to cascade deletes. If you select this option, when the wizard generates class definitions, it includes an implementation of the %OnDelete() callback method in those classes. The generated %OnDelete() method deletes all persistent objects that are referenced by the class. Do not select this option if you do select Use parent-child relationship; a parent-child relationship already provides similar logic.

      Note:

      If you modify the generated classes, be sure to modify the %OnDelete() callback method as needed.

    • If you generate persistent classes, the wizard can add a transient property to each object-type class so that you can project an InterSystems IRIS internal identifier for the objects. The choices are as follows:

      • None — If you select this option, the wizard does not add any of the properties described here.

      • Use Id — If you select this option, the wizard adds the following property to each object-type class:

        Property %identity As %XML.Id (XMLNAME="_identity", XMLPROJECTION="ATTRIBUTE") [Transient];
      • Use Oid — If you select this option, the wizard adds the following property to each object-type class:

        Property %identity As %XML.Oid (XMLNAME="_identity", XMLPROJECTION="ATTRIBUTE") [Transient];
      • Use GUID — If you select this option, the wizard adds the following property to each object-type class:

        Property %identity As %XML.GUID (XMLNAME="_identity", XMLPROJECTION="ATTRIBUTE") [Transient];
    • The table at the bottom lists XML namespaces in the schema. Here, specify the package to contain the classes for the XML namespace shown in that row. To do so, specify a package name in the Package Name field for that row.

  7. Select Next.

  8. On the next screen, specify the following options:

    • Java Enabled — If you select this option, each class includes a Java projection.

    • Data Population — If you select this option, each class extends %Populate in addition to %XML.Adaptor.

    • SQL Column Order — If you select this option, each property specifies a value for the SqlColumnNumber keyword, so that the properties have the same order in SQL that they have in the schema.

    • No Sequence Check — If you check this option, the wizard sets the XMLSEQUENCE parameter to 0 in the generated classes. This option is useful in some situations in which your XML files do not have elements in the same order as the XML schema.

      By default, the XMLSEQUENCE parameter is set to 1 in the generated classes. This ensures that the properties are included within the class definition in the same order as in the schema.

    • XMLIGNORENULL — If you select this option, the wizard adds XMLIGNORENULL=1 to the class definitions. Otherwise, it does not add this parameter.

    • Use Streams for Binary — If you select this option, the wizard generates a property is of type %Stream.GlobalBinary for any element of type xsd:base64Binary. If this option is clear, the property is of type %xsd.base64Binary instead.

      Note that the wizard ignores any attributes of type xsd:base64Binary.

    • Below the check boxes, the table lists the classes that the wizard will generate. For each class, make sure that Extends/Type is set appropriately. Here you choose one of the following:

      • Persistent — If you select this option, the class is a persistent class.

      • Serial — If you select this option, the class is a serial class.

      • Registered Object — If you select this option, the class is a registered object class.

      All generated classes also extend %XML.Adaptor.

    • In the right column of the table, select Index for each property that should be indexed.

  9. Select Finish.

The wizard then generates the classes and, if requested, compiles them.

For properties of these classes, if the corresponding element in the schema has a name that starts with an underscore (_), the name of the property starts with a percent sign (%).

See Also

FeedbackOpens in a new tab