Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Web Tools Guide
Previous Page Home Next Page

Generating XML files from XML schemas

You can generate an XML file from your XML schema if you want to quickly create an XML file based on your XML schema file. Generating an XML file from your XML schema saves you time by creating an XML file that is already associated with your XML schema, and contains at least some of the elements and attributes in your XML schema.

After you have generated your XML file, you can further customize it in the XML editor.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To generate an XML file from a schema file follow these steps:

  1. In the Navigator view, right-click the XML schema file that you want to work with and select Generate > XML File .
  2. Select a project or folder to contain the XML file and type a name for the file in the File Name field, then click Next. The name of the file must end in .xml.
  3. Select the Root element of the XML file. The root element of an XML file is the element that contains all other elements in that file. All of the global elements you have defined in the XML schema will be included in the Root element list. If you do not have any global elements in your XML schema, you cannot create an XML file from it.
  4. Select from the following content options:
    • Create optional attributes: both mandatory and optional attributes will be generated.
    • Create optional elements: both mandatory and optional elements will be generated.
    • Create first choice of required choice: the first option of a required choice will be generated in your XML file.
    • Fill elements and attributes with data: any elements and attributes generated will be filled with sample data.
    If you do not select any of these options, then only the minimum amount of content required for the XML file will be created.
  5. The Namespace Information section contains information about the target namespace of the XML schema, its prefix, and the schema location. Select the entry you want to edit and click Edit.
    • The value in the Namespace Name field is the target namespace of the XML schema. Your XML file should be associated with the same namespace as its XML schema is associated with.
    • All qualified elements and attributes in the XML file associated with the namespace will be prefixed with the Prefix value.
    • The Location Hint field contains the location of the XML schema.
    For more information about namespaces and namespace prefixes, refer to the related references.
  6. Click OK and then Finish.

The XML file will contain the selected root element and any elements or attributes contained in the root element. It also contains information about the XML file namespace and location. You can now add elements and attributes to the XML file.

Note: In certain cases, when an XML file is generated from a complex XML schema file, the XML file might not be valid. If this occurs, you can open the generated file in the XML editor and correct any errors that occur. Usually, only a few errors need to be fixed. The following XML schema constructs might present problems:
  • Restrictions: sometimes restricted elements are erroneously generated.
  • Facets: default generated data values might not conform to complex facets (for example, patterns).
  • Abstract elements: abstract elements are sometimes erroneously generated.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire