How Do I: Use XML Schema in WebLogic Workshop?

By adding XML schemas to your project, you can more easily write code that handles XML based on that schema. In WebLogic Workshop, you can create a "schema project" that is specifically designed to contain schema (XSD) files. You can specify that WebLogic Workshop compile schemas inside the project, generating XMLBeans types specifically designed to handle XML based on the schema.

Note: You use compiled XML Schema when creating XQuery maps. For more information, see Introduction to XQuery Maps. Also, if you're familiar with Ant, an XML-based tool for automating tasks, you may be interested in the xmlbean Ant task.

When you compile schema, you create a JAR file containing the generated types. The new JAR file will have the same name as your schema project, and will be placed in the Libraries folder in the Application window. As libraries, the generated types are on your application's classpath, and so are ready for use.

If there are errors during the compilation process, including errors in the schema itself, the errors will be displayed on the Build tab.

After compiling schema for XML used by your application, you can:

XML schema is a means for describing what a specific XML document should look like. For more information about XMLBeans, see Getting Started with XMLBeans.

  1. Get an XSD file containing the schema you need.

    If you don't have a schema, but would like to handle your XML using the types generated from schema, you can generate a schema from an XML instance document. For more information, see How Do I: Generate Schema from an XML Instance Document?

  2. Add a schema project if your app doesn't already have one.
  3. Specify whether you want the schema compiler to compile schemas as they change.
  4. Generate XMLBeans types from schema by adding the XSD file to the schema project.
  5. Use the XML Bean classes folder in the schema project to become acquainted with the types the generated XMLBeans expose.

To Add a Schema Project to an Application

  1. On the Application tab, right-click the top folder (with your application's name), then choose New -> Project.
  2. In the New Project dialog, in the left-hand pane, click Schema.
  3. In the right-hand pane, click Schema Project.
  4. In the Project name box, type the name to use for your new schema project.
  5. Create Create.

    WebLogic Workshop will create a new schema project and add it as a subfolder of your application.

  6. Right-click a schema project in your application, then choose Import.

    You can also drag the XSD file to the schema project.

  7. In the Import Files dialog, browse to the XSD file containing the schema from which XMLBeans types should be generated.
  8. Click Import.

    WebLogic Workshop will import the schema.

To Specify Auto-build for XML Schemas

  1. Right-click your schema project, then click Properties.
  2. In the Project Properties dialog, in the left pane, click Build.
  3. In the right pane, under Schema Project, select or clear the Auto-build when file changes occur check box.

Related Topics

Getting Started with XMLBeans