Generating an Instance Document for an XML Schema

You can generate a sample XML document instance that uses elements and attributes defined in an XML schema.

For example, you may need a document instance to test services that operate on documents using the schema. You can generate document instances using the XML Editor or the XSD Viewer.

  1. Open the schema in the XML Editor.

    If the schema is already open in the XML Editor, save any changes.

  2. Choose from the following:
    • In the XML Editor, select XML > Generate Instance Document.
    • In the XSD Viewer, select Schema > Generate Instance Document.
  3. Configure the following options:
    Table 1. Instance document generation
    Field Description
    Root Element Specify which element should be the root element.
    Create Optional Elements Specify whether to create child elements in parent element instances where they are optional .
    Create Optional Attributes Specify whether to add values for optional attributes.
    Repeat Count Specify how many instances of an element to add in contexts where the schema allows repeating elements.
  4. Click OK to generate the document instance.

    The generated document instance appears in a new XML Editor window.

    Note: Generated documents are read-only and are not created in the file system. To create a persistent copy, select File > Save As to save them to disk. You can edit the text after saving to disk.
Related concepts
XML Editor Outline View
Related tasks
Setting XML Editor Preferences
Configuring XML File Associations
Validating an XML Document Instance
Generating an XML Schema from a Document Instance
Pruning an XML Schema

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.