Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Schema generation plugin



The Document generation plugin allows to generate a Schema corresponding to an XML document.

Usage

If the currently selected tab is an XML file the "Convert to Schema" option is available for the Plugin:
convert2schema

Options

There are several options to generate the Schema:
  • The Generation strategy
  • The Enumeration limitation for attributes
  • The content type

convert2schema2

Generation strategy

There are 3 possible strategies:
  • Russian Doll: Only the top element is declared. Types are always defined inside the elements they define
  • Salami Slice: All elements are declared, but the type of each element is defined inside the element
  • Venetian Blind: Only the top-level element is declared. All other elements are declared through types

Content type

The default behavior is defining strings for all attributes. With the "Smart" type, the type of the attribute will be inferred from the values.

XMLBeans usage

Note that this plugin uses a repackaged version of the Apache xmlbeans project. It is packaged under a different package than in xmlbeans (which is org.apache.xmlbeans.impl.inst2xsd) to avoid clashes with the xmlbeans implementation which is used in Xerces.

Examples

Suppose the following XML file:
      <persons> 
         <person name="Peter" age="40" /> 
         <person name="Sophie" age="20" /> 
         <person name="Paul" age="51" /> 
      </persons>

Russian Doll result

      <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
         <xs:element name="persons"> 
            <xs:complexType> 
               <xs:sequence> 
                  <xs:element name="person" maxOccurs="unbounded" minOccurs="0"> 
                     <xs:complexType> 
                        <xs:simpleContent> 
                           <xs:extension base="xs:string"> 
                              <xs:attribute type="xs:string" name="name" use="optional"/> 
                              <xs:attribute type="xs:byte" name="age" use="optional"/> 
                           </xs:extension> 
                        </xs:simpleContent> 
                     </xs:complexType> 
                  </xs:element> 
               </xs:sequence> 
            </xs:complexType> 
         </xs:element> 
      </xs:schema>

Salami Slice result

      <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
         <xs:element name="person"> 
            <xs:complexType> 
               <xs:simpleContent> 
                  <xs:extension base="xs:string"> 
                     <xs:attribute type="xs:string" name="name" use="optional"/> 
                     <xs:attribute type="xs:byte" name="age" use="optional"/> 
                  </xs:extension> 
               </xs:simpleContent> 
            </xs:complexType> 
         </xs:element> 
         <xs:element name="persons"> 
            <xs:complexType> 
               <xs:sequence> 
                  <xs:element ref="person" maxOccurs="unbounded" minOccurs="0"/> 
               </xs:sequence> 
            </xs:complexType> 
         </xs:element> 
      </xs:schema>

Venetian Blind result

      <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
         <xs:element name="persons" type="personsType"/> 
         <xs:complexType name="personType"> 
            <xs:simpleContent> 
               <xs:extension base="xs:string"> 
                  <xs:attribute type="xs:string" name="name" use="optional"/> 
                  <xs:attribute type="xs:byte" name="age" use="optional"/> 
               </xs:extension> 
            </xs:simpleContent> 
         </xs:complexType> 
         <xs:complexType name="personsType"> 
            <xs:sequence> 
               <xs:element type="personType" name="person" maxOccurs="unbounded" minOccurs="0"/> 
            </xs:sequence> 
         </xs:complexType> 
      </xs:schema>

Categories: plugins

Copyright 2006-2016 Hervé. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences