xsd2fx - generates Xforms
Purpose

xsd2fx generates based on an XML schema a XForms form, which is embedded in an XHTML site.

Quick Start
Prerequisites

As xsd2xf.xsl is a single xslt script you can use it easily at any environment containing an appropriate XSL processor. So at least a current java runtime environment has to be installed.

Install as follows:

1. copy downloaded directories and files into an arbitrary <installation directory>.

Run Generation from os prompt
    proceed the following steps:
  • java net.sf.saxon.Transform test1.xsd scripts/xsd2xf.xsl -o output/test1.xhtml (Saxon) or
  • java org.apache.xalan.xslt.Process -in test1.xsd -xsl scripts/xsd2xf.xsl -out output/test1.xhtml (Xalan)

The process runs and ends without any message. After the programs terminates you should find a file called test1.xhtml in the output directory.

For further details concerning command-line start refer to :

either http://www.saxonica.com/documentation/using-xsl/commandline.html for using Saxon

or http://xml.apache.org/xalan-j/commandline.html for using Xalan

Running the transformation in this manner includes a well formed check but not a valid check. So make sure to use only valid schemata.

Approach

xsd2fx is designed to work as simple as possible. You can apply the script without any changes directly on your XML schema and get an result which can be used within further development steps. Though you have the possibility to refine the transformation by configuration. For further details see the section 'Usage'.

At least you can also adapt the script to your needs.

Features
Features

XForms control/construct

Transformation Mode

Status

Annotation

input/output controls

group

automatic

done

repeat

automatic

done

input

automatic

done

textarea

configure

done

secret

configure

done

output

configure

done

select1

automatic

done

select

automatic/configure

done

upload

./.

not planned

range

./.

not planned

complex list

?

not yet decided

generate control controls

trigger

configure

started

submit

configure

started

generate information attributes

label

automatic/configure

done

alert

automatic/configure

done

hint

automatic/configure

done

help

automatic/configure

done

generate control attributes

appearance

automatic/configure

majority done

navindex

configure

planned

selection=open

configure

planned

Transformation Rules

Mainstream of Transformation

element with attribute 'maxOccurs' >1 becomes: repeat control

element with 'sequence' subelement becomes: group control

element with 'sequence' subelement and attribute 'maxOccurs' >1 becomes: group control with subelement repeat control

element with 'restriction' subelement becomes: select1 control.

Source

Target

<xforms:group id="cost2GroupUI" appearance="full">
.
.

  <xforms:repeat id="cost2RepeatUI" appearance="compact" bind="B01300">
    <xforms:select1 id="cost2AccountUI" xforms:bind="B01400" xforms:appearance="minimal">
    .
    .
    <xforms:input id="cost2AmountUI" xforms:bind="B01500">
    </xforms:input>
  </xforms:repeat>
</xforms:group>
						
Transformation Rules in Detail Transformation Rules in Detail

determine appropriate xforms ui control

1

2

3

4

5

6

7

8

9

is an element

n

j

j

j

j

j

j

j

j

has a sequence as child or grandchild before another element as child or grandchild appears

-

n

n

n

n

n

n

j

-

minOccurs<1

-

n

n

n

n

n

?

-

maxOccurs>1 (incl. unbounded)

-

-

-

-

-

-

?

-

j

has a restriction as child or grandchild before another element as child or grandchild appears

-

n

n

n

n

j

j

-

-

annotation/appinfo/appearance=textarea

-

n

j

-

-

-

-

-

-

annotation/appinfo/appearance=secret

-

n

-

j

-

-

-

-

-

annotation/appinfo/appearance=output

-

n

-

-

j

-

-

-

-

generate group

x

generate repeat

x

generate input

x

x

generate secret

x

generate output

x

generate select1

x

generate select

x

generate repeat triggers

x

do nothing

x

done

x

x

x

x

x

x

todo

x

x

rules 5 and 6 needs some work

Usage

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

Run with ant

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.

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

Parse with ant

With the latter target within xsdtrans.xml script you can simply parse your schema.

Ant uses for xml parsing an optional task called 'XMLValidate'. For the prerequisites using this task please refer to http://ant.apache.org/manual/install.html, here the chapter concerning 'Optional Tasks'.

To parse your input schema simply type in at os prompt:

'ant -f xsdTransform.xml xsdparse'

Run within eclipse Einsatz in eclipse

The eclipse userinterface of xsdTransformer is realized as seperate project named xsdeclipse. you can download xsdeclipse plugin either via

xsdeclipse or

xsdtrans

For information concerning the usage within eclipse please refer to the xsdeclipse documentation.

Adapt with annotation/appinfo elements

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:

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>