xsdTransformer

Generates Code Based On XML Schema

description usable, to be completed.

2006-11-22

Revision History

Table of Contents

xsdTransformer

As xsd2xf.xml is a single xslt script you can use it easily at any environment with an appropriate xsl processor.

For standalone usage you can use the ant script xsdtrans.xml. This script consists of three targets. The first and second one are tranformation processes while the last one is a supplementary task which you can use to parse your input schema.

In xsdtrans.xml you can also see how to use the start parameters, which will be explained briefly in the following.

Table 5.  Brief Description

Parameter

Description

Required

in

location of xml schema file which is to be transformed.

(This parameter is used as input for ant's style and as input for the script. The script related parameter is only used for generating messages and can be omitted.)

valid values: existent file location including path relative to current directory (path/filename) or an absolute location (/path/filename)

default: none

yes

out

location of target file (here an xhtml file including XForms)

(This parameter is used as input for ant's style and as input for the script. The script related parameter is only used for generating messages and can be omitted.)

valid values: existent file location including path relative to current directory (path/filename) or an absolute location (/path/filename)

default: none

yes

style

location of name of the transformer script (including path relative to project directory).

(This parameter is used as input for ant's style and as input for the script. The script related parameter is only used for generating messages and can be omitted.)

valid values: existent file location including path relative to current directory (path/filename) or absolute location (/path/filename)

default: none

yes

force

Recreate target files, even if they are newer than their corresponding source files or the stylesheet. [ant manual]

valid values: yes/no

default: no

no

inElement

element which is used as root element. The root element is starting point of the transformation.

valid values: any string

default: none

no

outForm

desired name of the xforms form which is to generate.

valid values: any string

default: form1

no

language

language in which labels and messages will be transfered to the new form.

valid values: en (for english, de (for german)

default: en

no

bindPrefix

The id of bind elements is composed of a prefix and a current number. Sample:

<xforms:bind id="B00300" xforms:nodeset="vchr:title" xforms:required="true()" xforms:type="string"/>

With this parameter you can determine the value of this prefix.

valid values: any string

default: B

no

minRestrictionsForFull

This parameter determines the appearance of select1 and select controls. Is the amount of restrictions concerning a certain select* control is less than minRestrictionsForFull, the appearance of this control is set to 'minimal' otherwise it is set to 'full'.

valid values: any integer

default value: 4

generateAbsentAlert

If this parameter is set to 'yes' and no alert value is determined within the appinfo's (see configuration) the value of the alert element is derived by default from 'minOccurs' and 'type' attributes of the source element. Sample:

<xs:element name="title" type="xs:string" default="titleDefaultValue">

(when 'minOccurs' is omitted it means 'minOccurs=1', so input is required)

becomes

<xforms:input id="title" xforms:bind="B00300">

<xforms:label>title</xforms:label>

<xforms:alert>Input is obligative. Only input of type 'string' allowed.</xforms:alert>

<xforms:hint>hint for title</xforms:hint>

<xforms:help>help for title</xforms:help>

</xforms:input>

valid values: yes/no

default value: yes

no

generateAbsentHint

If this parameter is set to 'yes' and no hint value is determined within the appinfo's (see configuration) a hint element with a place holder value will be created. This value must be manually changed later. Sample:

<xs:element name="title"...>

becomes

<xforms:input id="title" xforms:bind="B00300">

.

<xforms:hint>hint for title</xforms:hint>

.

</xforms:input>

To avoid unnecessary manual work this parameter is set by default to 'no'.

valid values: yes/no

default value: no

no

generateAbsentHelp

If this parameter is set to 'yes' and no help value is determined within the appinfo's (see configuration) a help element with a place holder value will be created. This value must be manually changed later. Sample:

<xs:element name="title"...>

becomes

<xforms:input id="title" xforms:bind="B00300">

.

<xforms:help>help for title</xforms:help>

.

</xforms:input>

To avoid unnecessary manual work this parameter is set by default to 'no'.

valid values: yes/no

default value: no

no


In XML schema you can place schema neutral information within an element called annotation. annotation can contain two other elements. The first one is the documentation and second one is the appinfo element. As the names of these element say it is dedicated for documentation and application (controlling) purposes.

For affecting the behaviour of xsd2df you can place particular elements within annotation/appinfo. In detail:

Table 6.  Configuration by supplemental annotation/appinfo Elements

element

description

use for/within elements

label

Based on the value of this element xsd2xf contributes a nested element called label to the control element. If this element is absent and the process paramter generate absent labels is set to true, xsd2xf contributes also a nested label element and sets its value to the name of the control element. As label is an language sensitiv content, a nested element will be created for each language.

all

alert

Based on the value of this element xsd2xf contributes a nested element called alert to the control element. If this element is absent and the process paramter generate absent alerts is set to true, xsd2xf contributes also a nested alert element and sets its value to an appropriate message which is derived from the field contraints (field type, min. occurence) if their are any. As label is an language sensitiv content, a nested element will be created for each language.

all editable/changable

hint

Based on the value of this element xsd2xf contributes a nested element called hint to the control element. If this element is absent and the process paramter generate absent hints is set to true, xsd2xf contributes also a nested hint element as place holder for further treatment and sets its value to dummy text.

all

help

Based on the value of this element xsd2xf contributes a nested element called help to the control element. If this element is absent and the process paramter generate absent helps is set to true, xsd2xf contributes also a nested help element as place holder for further treatment and sets its value to dummy text.

all

appearance

Usual elements becomes usually input control elements in XForms. For affecting this standard you can set this element to:

  • textarea

  • secret

  • output

Another case are elements which become selectx control elements. In these cases you can overwrite the standard determination of the appearance attribute by setting this element to the desired value (minimal or full)

  • elements which become input control elements

  • elements which becomes selectx control elements.


If you are working with these supplementary elements and parse you parse your schema or a toll do, you might get error messages concerning these elements. You can avoid the appearance of such messages placinig an internal DTD subset into your XML Schema:

<?xml version="1.0"?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSchema 2001//EN" 
  "http://www.w3.org/2001/XMLSchema.dtd" [
  <!ELEMENT label (#PCDATA)>
  <!ELEMENT alert (#PCDATA)>
  <!ELEMENT hint (#PCDATA)>
  <!ELEMENT help (#PCDATA)>
  <!ATTLIST label xml:lang (en | de) "en">
  <!ATTLIST alert xml:lang (en | de) "en">
  <!ATTLIST hint xml:lang (en | de) "en">
  <!ATTLIST help xml:lang (en | de) "en">
]>
<xs:schema targetNamespace="http://xsdtrans.sourceforge.net/costVoucher" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  elementFormDefault="qualified" 
  attributeFormDefault="unqualified" 
  version="1.0">
  <xs:element name="voucher">
  .
  .
  </xs:element>
</xs:schema>