The xml.objSchema handles complex XML data structures using an XML Schema Definition (XSD). The XML Schema wizard helps you build binding files that can be used repeatedly to create and define XML Schemas.
An XSD must exist for this process. Always define a target Namespace in your XSD, as this prevents conflicts within your Studio Project, mainly in the classes that are generated as part of Schema creation.
Steps
- Create an XML Schema. (select from File > New in the main menu bar or use right-click options - New > Other > Schemas). This launches the XML Schema wizard.
- Choose among three options: import an XSD, use an existing bindings file to create your XML Schema, or update an existing bindings file. Each option requires its own set of steps, as described below.
-
IMPORT XSD: Select this option when importing the XSD into the Studio for the first time, or when updating an existing bindings file in your Project - basically overwriting the older bindings file (by basically re-importing the XSD). The XML Schema is read-only.
- Select the XSD from a filesystem or Workspace location.
- Select the Package.
- The Override Package checkbox indicates how the Schema reacts if there are undefined target Namespaces in the XSD. When multiple XSDs contain the same XML elements without the targetNamespace defined, classloading conflicts occur, which affect Ruleset mapping and can cause runtime errors. The checkbox helps the Studio determine the package to which the classes will be generated.
- When selected, the Override Package defined here will be used for those XSD Elements that do not have a targetNamespace defined.
- When not selected, then all XSD Elements use the Override Package defined in the field above.
Note: in rare cases in which a bindings file has been generated and contains the same packages or target namespaces, the checkbox should not be selected; this will force an override of the destination package for the generated bindings.
- Validate the XSD (using the Validate button). Potential classpath conflicts will be checked as part of validation (see next step), and detailed error messages will be provided.
- Select Root Elements for Schema Generation. All Root Elements in the XSD are shown in the Available Classes pane. Make sure to select and move the Element(s) from Available to Selected.
Result: The Studio generates an XML Schema, a bindings file, and other resources used to build and read XML files. The XSD is also copied into the Project under an xsd folder.
-
USE EXISTING BINDINGS: This option allows you to create another XML Schema based on an existing bindings file from an XSD that was previously imported into the Studio. For example, the first time the XSD was imported only some of the elements were chosen for an XML Schema; now other elements from the XSD will be used in a different XML Schema.
- Select the bindings file from Workspace.
- Select Root Elements for Schema Generation. All Root Elements in the XSD are shown in the Available Classes pane. Make sure to select and move the Element(s) from Available to Selected.
- Press Finish.
Result: The Studio generates an XML Schema based on the selected bindings file.
-
UPDATE EXISTING BINDINGS: This option allows you to update or override an existing bindings file (which could then be used the next time you create a schema using an existing bindings file).
- Select the bindings file from Workspace.
- Select the XSD from a filesystem or Workspace location.
- The Override Package checkbox indicates how the Schema reacts if there are undefined target Namespaces in the XSD. When multiple XSDs contain the same XML elements without the targetNamespace defined, classloading conflicts occur, which affect Ruleset mapping and can cause runtime errors. The checkbox helps Studio determine the package to which the classes will be generated.
Note: The previously-set override package value should already be displayed. As long as this value remains unchanged, the Studio generates the bindings with the same value.
- Validate the XSD (using the Validate button). Potential classpath conflicts will be checked as part of validation, and detailed error messages will be provided if necessary.
- Press Finish.
Result: The Studio updates the selected bindings file, but does not create a Schema.
-
This task is complete. To use the XML Schema, select it when creating Rulesets.
Comments
0 comments
Please sign in to leave a comment.