Edit online

You can organize an XML schema linked by xs:include and xs:import statements on several levels. In some cases, working on such a schema as if it were a single file is more convenient than working on multiple files separately. The Flatten Schema operation allows you to flatten an entire hierarchy of XML schemas. Starting with the main XML schema, Oxygen XML Editor calculates its hierarchy by processing the xs:include and xs:import statements.

The Flatten Schema action is available from the Tools menu or the contextual menu in Text mode. The action opens the Flatten Schema dialog box that allows you to configure the operation.

Figure 1: Flatten Schema Dialog Box
For the main schema file and for each imported schema, a new flattened schema is generated in the specified output folder. These schemas have the same name as the original ones.
Note: If necessary, the operation renames the resulted schemas to avoid duplicated file names.

A flattened XML schema is obtained by recursively adding the components of the included schemas into the main one. This means Oxygen XML Editor replaces the xs:include, xs:redefine, and xs:override elements with the ones coming from the included files.

Options in the Flatten Schema Dialog Box

The following options are available in the Flatten Schema dialog box:

File name
The name of the output file.
Output directory
The path of the output directory where the flattened schema file will be saved.
Open the flattened XML Schema file in editor
Opens the main flattened schema in the editing area after the operation completes.
Use the XML Catalogs when collecting the referenced XML Schemas
Enables the imported and included schemas to be resolved through the available XML Catalogs.
Note: Changing this option triggers the recalculation of the dependencies graph for the main schema.
Process the imported XML Schemas resolved through the XML Catalogs
Specifies whether or not the imported schemas that were resolved through an XML Catalog are also processed.
Flatten the imported XML Schema(s)
Specifies whether or not the imported schemas are flattened.
Note: For the schemas skipped by the flatten operation, no files are created in the output folder and the corresponding import statements remain unchanged.

Flatten Schema from the Command Line

The Flatten Schema tool can be also ran from command line by using the following command:
  • flattenSchema.bat on Windows
  • sh flattenSchema.sh on OS X and Linux
The command line accepts the following parameters:
  • -in:inputSchemaURL - The input schema URL.
  • -outDir:outputDirectory - The directory where the flattened schemas should be saved.
  • -flattenImports:<boolean_value> - Controls whether or not the imported XML Schemas should be flattened. The default value true.
  • -useCatalogs:<boolean_value> - Controls if the references to other XML Schemas should be resolved through the available XML Catalogs. The default value false.
  • -flattenCatalogResolvedImports:<boolean_value> - Controls whether or not the imported schemas that were resolved through the XML Catalogs should be flattened. The default value is true.
    Note: This option is used only when -useCatalogs is set to true.
  • -verbose - Provides information about the current flatten XML Schema operation.
  • --help | -help | --h | -h - Prints the available parameters for the operation.
Example: Command-Line Example for Windows
flattenSchema.bat -in:http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd 
   -outDir:mySchemas/flattened/xhtml -flattenImports:true -useCatalogs:true 
      -flattenCatalogResolvedImports:true -verbose
Example: Command-Line Example for OS X
sh flattenSchema.sh -in:http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd 
    -outDir:mySchemas/flattened/xhtml -flattenImports:true -useCatalogs:true 
       -flattenCatalogResolvedImports:true -verbose
Example: Command-Line Example for Unix/Linux
sh flattenSchema.sh -in:http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd 
     -outDir:mySchemas/flattened/xhtml -flattenImports:true -useCatalogs:true 
        -flattenCatalogResolvedImports:true -verbose