Xtool/SchemaList: Difference between revisions

From tehowiki
Jump to navigation Jump to search
imported>Gfis
from documentation.html
 
imported>Gfis
better tables
Line 48: Line 48:
   ...
   ...
=== Example for output in MS-Excel ===
=== Example for output in MS-Excel ===
[[Image:documentation/list-mtsv.jpg|frame|none|alt=list-mtsv.jpg|caption schema list in Excel worksheet]]
[[File:File.jpg|caption Schema list in Excel worksheet]]


The columns of the Excel worksheet are filled as follows:
The columns of the Excel worksheet are filled as follows:
<nowiki><table>
{| class="wikitable" style="text-align:left"
<tbody>
|- class="header"
<tr class="odd">
| align="left" | A
  <td align="left">A</td>
| align="left" | indented elements with generated values
  <td align="left">indented elements with generated values</td>
|- class="even"
  </tr>
| align="left" | B
<tr class="even">
| align="left" | cardinality, multiplicity: minOccurs and maxOccurs
  <td align="left">B</td>
|- class="odd"
  <td align="left">cardinality, multiplicity: minOccurs and maxOccurs</td>
| align="left" | C
  </tr>
| align="left" | schema type
<tr class="odd">
|- class="even"
  <td align="left">C</td>
| align="left" | D
  <td align="left">schema type</td>
| align="left" | elementary XML datatype
</tr>
|- class="odd"
  <tr class="even">
| align="left" | E
  <td align="left">D</td>
| align="left" | restrictions: string lengths, number ranges, patterns, value enumerations
  <td align="left">elementary XML datatype</td>
|- class="even"
  </tr>
| align="left" | F
<tr class="odd">
| align="left" | annotations attached to the element
  <td align="left">E</td>
|- class="odd"
  <td align="left">restrictions: string lengths, number ranges, patterns, value enumerations</td>
| align="left" | G
  </tr>
| align="left" | absolute XPath to this element node
<tr class="even">
|- class="even"
  <td align="left">F</td>
| align="left" | H
  <td align="left">annotations attached to the element</td>
| align="left" | a single &quot;;&quot; in all relevant (non-descriptive) rows, useful for hiding rows
  </tr>
|}
<tr class="odd">
  <td align="left">G</td>
  <td align="left">absolute XPath to this element node</td>
</tr>
  <tr class="even">
  <td align="left">H</td>
  <td align="left">a single &quot;;&quot; in all relevant (non-descriptive) rows, useful for hiding rows</td>
</tr>
</tbody>
</table></nowki>


=== Special Rows ===
=== Special Rows ===
Line 97: Line 87:


The values are generated with a fixed set of rules which depend on the elementary data type, sometimes the schema type, and the restrictions. The following table shows these rules:
The values are generated with a fixed set of rules which depend on the elementary data type, sometimes the schema type, and the restrictions. The following table shows these rules:
<nowiki><table>
{| class="wikitable" style="text-align:left"
<thead>
|- class="header"
<tr class="header">
! align="left" | Datatype
  <th align="left">Datatype</th>
! align="left" | Restriction, Schema Type
  <th align="left">Restriction, Schema Type</th>
! align="left" | Generated Value
  <th align="left">Generated Value</th>
|-
</tr>
| align="left" | boolean
  </thead>
| align="left" |  
<tbody>
| align="left" | true
<tr class="odd">
|-
<td align="left">boolean</td>
| align="left" | decimal
  <td align="left"> </td>
| align="left" |  
  <td align="left">true</td>
| align="left" | 1
</tr>
|-
  <tr class="even">
| align="left" | dateTime
<td align="left">decimal</td>
| align="left" |  
  <td align="left"> </td>
| align="left" | 2007-06-29T04:30:00Z   (?)
  <td align="left">1</td>
|- class="even"
</tr>
| align="left" | date
  <tr class="odd">
| align="left" |  
<td align="left">dataTime</td>
| align="left" | 2007-06-29
  <td align="left"> </td>
|- class="odd"
  <td align="left">2007-06-29T04:30:00Z   (?)</td>
| align="left" | NCName
  </tr>
| align="left" |  
<tr class="even">
| align="left" | NCName
  <td align="left">date</td>
|- class="even"
  <td align="left"> </td>
| align="left" | decimal
  <td align="left">2007-06-29</td>
| align="left" |  
  </tr>
| align="left" | 1
<tr class="odd">
|- class="odd"
  <td align="left">NCName</td>
| align="left" | string
  <td align="left"> </td>
| align="left" | (pattern)
  <td align="left">NCName</td>
| align="left" | (the characters from the pattern repeated up to a minimal length)
  </tr>
|- class="even"
<tr class="even">
| align="left" | string
  <td align="left">decimal</td>
| align="left" | (length)
  <td align="left"> </td>
| align="left" | (schema type name truncated or padded with letters)
  <td align="left">1</td>
|- class="odd"
</tr>
| align="left" | string
  <tr class="odd">
| align="left" | (enumeration)
  <td align="left">string</td>
| align="left" | (the first alternative)
  <td align="left">(pattern)</td>
|- class="even"
  <td align="left">(the characters from the pattern repeated up to a minimal length)</td>
| align="left" | string
  </tr>
| align="left" | CurrencyCode
<tr class="even">
| align="left" | EUR
  <td align="left">string</td>
|- class="odd"
  <td align="left">(length)</td>
| align="left" | string
  <td align="left">(schema type name truncated or padded with letters)</td>
| align="left" | IBANIdentifier
</tr>
| align="left" | DE28500400000123456589
  <tr class="odd">
|- class="even"
  <td align="left">string</td>
| align="left" | string
  <td align="left">(enumeration)</td>
| align="left" | BICIdentifier
  <td align="left">(the first alternative)</td>
| align="left" | COBADEFF
</tr>
|- class="odd"
  <tr class="even">
| align="left" | string
  <td align="left">string</td>
| align="left" | BEIIdentifier
  <td align="left">CurrencyCode</td>
| align="left" | PUTMDEEM
  <td align="left">EUR</td>
|- class="even"
  </tr>
| align="left" | string
<tr class="odd">
| align="left" | CHIPSUniversalIdentifier
  <td align="left">string</td>
| align="left" | CH012345
  <td align="left">IBANIdentifier</td>
|}
  <td align="left">DE28500400000123456589</td>
  </tr>
<tr class="even">
  <td align="left">string</td>
  <td align="left">BICIdentifier</td>
  <td align="left">COBADEFF</td>
  </tr>
<tr class="odd">
  <td align="left">string</td>
  <td align="left">BEIIdentifier</td>
  <td align="left">PUTMDEEM</td>
</tr>
  <tr class="even">
  <td align="left">string</td>
  <td align="left">CHIPSUniversalIdentifier</td>
  <td align="left">CH012345</td>
</tr>
</tbody></nowki>
</table>

Revision as of 08:50, 2 September 2016

SchemaList - List the Element Tree of a W3C XML Schema

Starting with the first xs:element definition, the type hierarchy of a W3C schema file is recursively expanded. The output is a linear, indented list of the unfolded possible substructures, the leaf XML elements and their attributes.

Optionally values may be generated, and the tool can generate comments which show the schema type, data type, restrictions and annotations attached to the elements. With value generation and a selection of the first choice, the output will be a well-formed XML instance which usually validates against the input schema. This representation has the big advantage that it shows both the schema design and a real instance of that schema, both combined in a single XML document.

The schema list can be shown as HTML (the default), plain text, pure XML or in tab separated format which is suitable for MS-Excel. For HTML, the start tags have a link showing the XPath to the element. In Excel, columns can easily be hidden or appended. Such a worksheet is then a good base for the development of additional restrictions, mapping rules and the like.

The tool may be called on a commandline or from a web page. The following optional settings may be specified:

  • -c show comments with types, restrictions, patterns etc.
  • -e enc source file encoding, default: UTF-8
  • -e enc target file encoding, default: UTF-8
  • -f show first alternative of choices only
  • -m mode output mode: "html" (default), "plain", "tsv" (for MS-Excel) or "xml"
  • -s show start tags only (no end tags)
  • -v generate element values

These options may be combined. Typical settings are:

  • -cvf generate a well-formed, commented XML instance from the schema
  • -s only show the minimal indented element structure without end tags
  • -cv -m tsv generate an Excel worksheet with comments and values
  • -v -m xml show elements with values in the browser's XML representation (elements can be collapsed)
  • -vf -m plain generate a concise XML instance file which may be stored and validated

In the web interface, the user specifies the desired options and uploads the input schema file to the application on the web server.

Example for HTML output (-cv -m html)

<Document xmlns="urn:sepade:xsd:pain.001.001.02%22><!--[1..1] Document -->
     <pain.001.001.02><!--[1..1] pain.001.001.02 -->
         <GrpHdr><!--[1..1] GroupHeader20 -->
             <MsgId>Max35Text</MsgId><!--[1..1] Max35Text string 1..35 -->
             <CreDtTm>2007-06-29T05:30:00Z</CreDtTm><!--[1..1] ISODateTime dateTime -->
             <NbOfTxs>09</NbOfTxs><!--[1..1] Max15NumericText string /[0-9]{1,15}/ -->
             <CtrlSum>1</CtrlSum><!--[0..1] DecimalNumber decimal L18.17 ! SEPA AOS Can optionally be used as specification for the total amount of the file. -->
             <Grpg>GRPD</Grpg><!--[1..1] Grouping2Code string "GRPD" ! Only the GRPD option may be used.-->
             <InitgPty><!--[1..1] PartyIdentification20 ! Initiating party. -->
                 <Nm>Max70Text</Nm><!--[1..1] Max70Text string 1..70 ! AT-02 Name of the originator.-->
                 <PstlAdr><!--[0..1] PostalAddress5 ! AT-03 Address of the originator.-->
                     <AdrLine>Max70Text</AdrLine><!--[1..2] Max70Text string 1..70 -->
                     <Ctry>AZ</Ctry><!--[1..1] CountryCode string /[A-Z]{2,2}/ -->
                 </PstlAdr>
                 <Id><!--[0..1] Party5Choice ! AT-10 - ID of the originator. Recommendation: This field should not be used.-->
                     <__unresolvedChoice__><!--[1..1] -->
                       <OrgId><!--[1..1] OrganisationIdentification2 -->
                           <BIC>COBADEFF</BIC><!--[0..1] BICIdentifier string /[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}/ -->
                           <IBEI>AZBDFHJNP0</IBEI><!--[0..1] IBEIIdentifier string /[A-Z]{2,2}[B-DF-HJ-NP-TV-XZ0-9]{7,7}[0-9]{1,1}/ -->
                           <BEI>BEIADEFF</BEI><!--[0..1] BEIIdentifier string /[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}/ -->
                           <EANGLN>0909090909090</EANGLN><!--[0..1] EANGLNIdentifier string /[0-9]{13,13}/ -->
 ...

Example for output in MS-Excel

caption Schema list in Excel worksheet

The columns of the Excel worksheet are filled as follows:

A indented elements with generated values
B cardinality, multiplicity: minOccurs and maxOccurs
C schema type
D elementary XML datatype
E restrictions: string lengths, number ranges, patterns, value enumerations
F annotations attached to the element
G absolute XPath to this element node
H a single ";" in all relevant (non-descriptive) rows, useful for hiding rows

Special Rows

There are two sorts of special rows which are useful for the description of the schema, but which will not lead to a valid XML instance.

  1. With option "-c", any attribute is shown on separate line starting with "@", since attributes also have types, restrictions etc.</>
  2. Without option "-f", any <xs:choice> leads to an artificial element <__unresolvedChoice__> in order to make visible that this choice must still be resolved to yield a valid XML instance. This resolution could be realized by an XSLT stylesheet or by manual editing.

Value Generation

The tool tries to generate validating values for the most common cases. This works rather well for the ISO 20022 message schemata relevant to SEPA (camt, pacs, pain families), but it will possibly fail for complicated patterns or different application areas.

The values are generated with a fixed set of rules which depend on the elementary data type, sometimes the schema type, and the restrictions. The following table shows these rules:

Datatype Restriction, Schema Type Generated Value
boolean   true
decimal   1
dateTime   2007-06-29T04:30:00Z   (?)
date   2007-06-29
NCName   NCName
decimal   1
string (pattern) (the characters from the pattern repeated up to a minimal length)
string (length) (schema type name truncated or padded with letters)
string (enumeration) (the first alternative)
string CurrencyCode EUR
string IBANIdentifier DE28500400000123456589
string BICIdentifier COBADEFF
string BEIIdentifier PUTMDEEM
string CHIPSUniversalIdentifier CH012345