XML Schemas
A schema definition is a formal description that defines the exact structure of an XML file and includes the element names and data types.
These terms of schemas are also called XML Structures.
It is easy to transform XML data from one format to another using an XML transform (xslt)
A schema definition file contains schema tags that enforce rules, such as data type and validation.
(XDS) file extension
Using XML Schemas
You can either create and use your own XML schemas or you can let Excel create one for you automatically.
XML Schemas that are created automatically by Excel are called Inferred Schemas
When Excel imports an xml file that does not explicitely reference an XML schema Excel will automatically "infer" one.
XML Schemas can be imported and saved into workbooks to allow XML to be easily and accurately imported and exported.
XML Schemas that are saved into a workbook are referred to as XML Maps since they are used to map an external data file to the workbook.
Editing a Schema
You can edit a schema outside of Excel by using an XML Editor.
Try and use a full-featured XML Editor as schemas may not include any whitespace or linefeeds (for example the ones generated by Excel).
Open the schema and save the changes.
Open the workbook
Click "Refresh XML Data" to verify that the schema is still valid.
Inferred Schemas
If you import XML data into a workbook without adding an XML schema, Excel will try to create a schema for you based on the tags that are defined in the XML data file.
Inferred schemas are also saved in the workbook.
When you work with imported XML data that has an inferred schema, you can also customize the XML Source task pane.
Select the Preview Data in Task Pane option from the Options button to display the first row of data as sample data in the element list, if you imported XML data associated with the XML map in the current session of Excel.
Inferring a schema is fine as long as:
There nodes don't contain any optional items.
The first occurrence of each node contains all its possible children.
You cannot export the Excel inferred schema as a separate XML schema data file (.xsd).
Although there are XML schema editors and other methods for creating an XML schema file, you may not have convenient access to them or know how to use them.
As an alternative, you can use the Excel 2003 XML Tools Add-in Version 1.1, which can create a schema file from an XML map.
For more information, see Using the Excel 2003 XML Tools Add-in Version 1.1.
Validating a Schema - Manually
(Data > XML > XML Map properties)
Select "Validate data against schema for import and export" and press OK.
An error will be displayed if the XML doesn't conform to the schema.
Excel checks the XML against the schema whenever the XML data is imported, exported or refreshed.
You can get detailed information about the error by clicking Details on the XML Import Error dialog box
SS
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext