The schema sources are the starting point of the design, and design structure can be influenced by: (i) choices you make during schema selection, and (ii) the root elements you select in the schema.
The selection of the schema for a new SPS file can be done in the following ways:
1.Click File | New and directly select a schema source to add via one of the methods (except New (empty)) available in the menu that pops up.
2.Click File | New, select New (empty) from the menu that pops up. After the new SPS is created and displayed in the GUI, in the Design Overview sidebar, select the Add New Schema command. This pops up a a menu listing the methods you can use to add different types of schemas (screenshot below). Each command in this menu is described in the sub-sections of this section.
The schema source can be selected from a file, from a DB, or be an XBRL taxonomy or user-defined. An important point to consider is whether you will be using global templates, and whether elements you wish to create as global templates are defined as global elements in the schema. When adding a DTD from file, remember that all elements defined in the DTD are global elements. When adding an XML Schema from file, it is worth checking what elements are defined as global elements and, should you wish to make any change to the schema, whether this is permitted in your XML environment. When a DB is selected, during the import process, you can select what tables from the DB to import. This selection determines the structure of the XML Schema that will be generated from the DB.
|Note:||You can select multiple schemas, of which one schema is designated the main schema (right-click the schema in the Design Overview sidebar and select Set As Main Schema). The document node of the main schema is the entry point of the main template. The selection and presence of subsidiary schemas in the schema sources enable nodes from these schemas to be included in the design.|
|Note:||If you wish to add a namespace to an SPS or to an XSLT stylesheet being generated from an SPS, the namespace must be added to the top-level schema element of the XML Schema on which the SPS is based.|
If a schema source has multiple global elements, then multiple root elements (document elements) can be selected for use in the design. This enables the SPS design to have templates that match multiple document elements. The advantage of this is that if an SPS, say UniversalSPS.sps, based on UniversalSchema.xsd has one template each for its two root elements, Element-A and Element-B, then this one SPS can be used with an XML instance document which has Element-A as its document element as well as with another XML instance document which has Element-B as its document element. For each XML instance, the relevant template is used, while the other is not used. This is because for the document element of each XML instance document, there is only one template in the SPS which matches that document element. For example, the document element /Element-A will be matched by the template which selects /Element-A but not by that which selects /Element-B. In this connection, it is important to remember that if multiple global elements are defined in the schema, an XML document with any one of these global elements as its document element is valid (assuming of course that its substructure is valid according to the schema).
To set up the SPS to use multiple root elements (document elements), click the button to the right of the /Root elements entry of the schema. The following dialog pops up.
The dialog lists all the global elements in the schema. Select the global elements that you wish to use as root elements (document elements) and click OK. The selected element/s will be available as root document elements and will be displayed in the Root Elements list. A template can now be created for each of these document elements. Each of these templates serves as an alternative root element template. When an XML document is processed with this SPS, only one of the alternative root element templates will be used: the one that matches the root (or document) element of the XML document.
So, when an XML document having Element-A as its document element is processed with this SPS, then the root template in the SPS that matches Element-A is triggered, while all the other root element templates in the SPS are ignored. If an XML document having Element-B as its document element is processed, then the root template in the SPS that matches Element-B is triggered, while all other root element templates in the SPS are ignored. In this way a single SPS can be used to process two or more XML documents, each of which has a different root (or document) element.