You can organize an XML schema on several levels linked by xs:include and
xs:import statements. In some cases, working on such a schema as on a
single file is more convenient.
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. This action is available from the contextual menu of the editor or from the Tools menu.
Figure: Flatten Schema Dialog Box
For the main schema file and for each imported schema, a new flattened schema is generated in
the 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.
Note: You
can choose the output folder and the name of each generated schema file.
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.
The following options are available in the
Flatten Schema dialog box:
- 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 resolving the imported and included schemas 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 the imported schemas that were resolved through
an XML Catalog are flattened
- Flatten the imported XML Schema(s) - specifies whether 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.
To flatten a schema from the command line, use the following command:
- flattenSchema.bat on Windows
- sh flattenSchemaMac.sh on OS X
- sh flattenSchema.sh on Unix/Linux
The command line accepts the following parameters:
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
Command Line Example for OS X
sh flattenSchemaMac.sh -in:http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd -outDir:mySchemas/flattened/xhtml -flattenImports:true -useCatalogs:true -flattenCatalogResolvedImports:true -verbose
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