# Importing Schemas

In this task, you import your schemas into your application. The following schema types are supported:

- XML Schema—W3C XML Schema files describe and constrain the content of XML documents. (The XSD files that contain XML Schemas end in the .xsd extension.)

Note: Multiple namespaces in XML and XSD files are supported in WebLogic Workshop. For example, you can transform two source XML files valid to different namespace to another XML file which is valid to a third namespace. To learn more, see Understanding the Transformation of the Tutorial: Building Your First Data Transformation.

- MFL—MFL (Message Format Language) documents describe and constrain the content of non-XML data. For example, data coming from COBOL copybooks and C structure definitions. (MFL files are created using the Format Builder and end in the .mfl extension. For instructions on using Format Builder, see Using Format Builder to Create Format Schemas (MFL Files).)

Note: The file name of the MFL document becomes the namespace of the MFL elements.

When a schema (described in an XSD or MFL file) is imported into your application, representations of these schemas are available in some of the panes of WebLogic Workshop. In addition, Java interfaces for accessing the data represented in the schemas are generated. To learn more about these Java classes see Java Classes Created From Importing Schemas.

Note: Due to a Windows operating system limitation on file path lengths (256 characters), you might have trouble compiling schemas in which the generated types are nested in a very deep package hierarchy. This may result in an error message stating that a particular class couldn't be found. To work around this limitation, try using an xsdconfig file to guide the naming of generated packages so that the hierarchy is less deep, package names are shorter, etc. For more information, see How Do I: Guide XMLBeans Type Naming During Schema Compilation?.

### Importing an XML Schema (XSD file)

When an XSD file (which contains an XML Schema) is imported into a Schema project folder of a WebLogic Workshop application, a build of the application is triggered which generates XMLBeans based on the imported XML Schema. The XML Beans provides Java classes for accessing the XML data that conforms to the imported XML Schema. These Java classes are available as XML types in the type system of the application. To learn more, see Getting Started with XMLBeans.

After XML Beans are generated for an XML Schema, the following options are enabled in WebLogic Workshop:

- The ability to create an XML business process variable of the XML Schema type from the Data Palette of a business process. The Data Palette of a business process is available when a JPD file is active in WebLogic Workshop. (If the Data Palette is not visible with a JPD file active, choose View —> Windows —> Data Palette from the menu bar.) To learn more about business process variables, see Creating Variables.
- The ability to select the XML types as a source or target type for a transformation. To learn more, see To Select the Source and Target Types and To Change the Selected Source or Target Parameters.
- The ability to select a displayed XML type from Data Palette of the mapper. (The XML Schema type must be selected as a source or target type in order for it visible in the Data Palette of the mapper.) The Data Palette of the mapper is available when an XQ file is active is WebLogic Workshop. An XQ file contains a query which is written in the XQuery language. (If the Data Palette is not visible, with a XQ file active, choose View —> Windows —> Data Palette from the menu bar.) To learn more about mapper variables, see Using the Data Palette of the Mapper.

Note: The Data Palette of the mapper displays a different set of variables than the variables displayed in the Data Palette for business processes (JPDs). The variables displayed in the Data Palette of the mapper are used only in transformations and are distinct from the variables used in business processes.

### Importing an MFL File

When an MFL file (which contains a schema describing non-XML data) is imported into a Schema project folder of a WebLogic Workshop application, a build of the application is triggered which generates XML Beans and MflObject class based on the schema in the imported MFL file. From the definitions in the MFL file, Non-XML types as well as XML types (from the schema in the MFL file) are available in the type system of the application.

The generated MflObject Java class provides methods for the conversion between non-XML and XML data, programmatically outside the mapper functionality of WebLogic Workshop. To learn more, see Java Classes Created From Importing Schemas.

The generated XML Bean classes provide methods for access the data that conforms to an MFL file. To learn more about the XML Schema representations generated from an MFL file see Java Classes Created From Importing Schemas. To learn more about XMLBeans, see Getting Started with XMLBeans.

After XML Beans are generated for the schema defined in the MFL file, the following options are enabled in WebLogic Workshop:

- The ability to create a Non-XML business process variable (that conforms to the schema in the MFL file) from the Data Palette of a business process. (If the Data Palette is not visible with a JPD file active, choose View —> Windows —> Data Palette from the menu bar.) For example, if a StockQuotes.mfl is imported into a Schemas project a StockQuotes.mfl node is visible from the Create Variable pane for the Non-XML variable type. To launch the Create Variable pane, choose Add —> Non-XML in the top right-hand corner of the Data Palette pane when a JPD is active. This is an internal representation of the XML Schema not available outside of WebLogic Workshop. To learn more about business process variables, see Creating Variables.
- The ability to create an XML business process variable derived from the schema in the MFL file from the Data Palette of a business process. (If the Data Palette is not visible, with a JPD file active, choose View —> Windows —> Data Palette from the menu bar.) For example, if a StockQuotes.mfl is imported into a Schemas project a StockQuotes.xsd.mfl node is visible from the Create Variable pane for the XML variable type. To launch the Create Variable pane, choose Add —> XML in the top right-hand corner of the Data Palette pane when a JPD is active. This is an internal representation of the XML Schema not available outside of WebLogic Workshop. To learn more about business process variables, see Creating Variables.
- The ability to select the Non-XML type or the XML type (derived from definitions in the MFL file) as a source or target type for a transformation in the Configure XQuery Transformation Method pane. When you select the Non-XML or XML type as a source type for a transformation, a variable of the source type is displayed in the Data Palette of the mapper.

Note: The Raw Data type represents unstructured Non-XML data. This type is not available in data transformation.

- The ability to select a displayed schema type (derived from the MFL file) in the Data Palette of the mapper. (The XML Schema type must be selected as a source or target type in order for it visible in the Data Palette of the mapper.) The Data Palette of the mapper is available when an XQ file is active is WebLogic Workshop. An XQ file contains a query which is written in the XQuery language. (If the Data Palette is not visible, with a XQ file active, choose View —> Windows —> Data Palette from the menu bar.) To learn more see Using the Data Palette of the Mapper.

Note: The Data Palette of the mapper displays a different set of variables than the variables displayed in the Data Palette for business processes (JPDs). The variables displayed in the Data Palette of the mapper are used only in transformations and are distinct from the variables used in business processes.

To make the schemas in XSD and MFL files available in your process application, you must import them into a Schemas project folder. (To learn more, see a Creating Schemas Projects.) You can import XSD and MFL files into a Schemas project folder, by following the steps described in one of the following tasks:

- To Import an XSD or MFL file Into Your Application Using the Import Option of the Schemas Folder Drop-Down Menu
- To Import an XSD or MFL file Into Your Application Using Drag-And-Drop

To Import an XSD or MFL file Into Your Application Using the Import Option of the Schemas Folder Drop-Down Menu

In this task, you import XSD or MFL files using the Import option of the drop-down menu of a Schemas project folder.

1. In the Application tab, right-click on a Schemas project folder. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)
2. From the drop-down menu, select Import... .

The Import Files dialog box is displayed.

3. Browse the file system, and select your XSD file (ends in the.xsd extension) or MFL file (ends in the.mfl extension), and click Import.

The schema in the XSD or MFL file is imported. This triggers a build of the current Schemas project folder. (The build verifies that the schema file is well formed. For XSD files, it also verifies that the element and attribute names in the XML Schema do not conflict with the XSD files that have already been imported into the current Schemas project folder.)

Any errors that occur when compiling your XSD and MFL files will be displayed in the WebLogic Workshop Build tab. For all of the XSD and MFL files imported into a Schema project, you must fix any reported errors before you will be able to use these schemas in business processes or transformations.

To Import an XSD or MFL file Into Your Application Using Drag-And-Drop

In this task, you import XSD or MFL files by dragging-and-dropping them into a Schemas project folder.

In a Windows Explorer pane, select the XSD or MFL file and drag it into a Schemas folder. (If the Application tab is not visible in WebLogic Workshop, choose View —> Application from the menu bar.)

The schema in the XSD or MFL file is imported. This triggers a build of the current Schemas project folder. (The build verifies that the schema file is well formed. For XSD files, it also verifies that the element and attribute names in the XML Schema do not conflict with the XSD files that have already been imported into the current Schemas project folder.)

Any errors that occur when compiling your XSD and MFL files will be displayed in the WebLogic Workshop Build pane. For all of the XSD and MFL files imported into a Schema project, you must fix any reported errors before you will be able to use these schemas in business processes or transformations.

Note: Outside of WebLogic Workshop, you can also copy XSD or MFL files directly into a Schemas project folder in the file system. For example, if your application saved in the C:\user_projects\applications\myApp directory contains the default Schemas project, you can save the MFL file directly into this C:\user_projects\applications\myApp\Schemas directory in the file system. This will trigger a build of the current Schemas project folder in WebLogic Workshop.