Schema to XForms stylesheet

Matthew Graham mjg at cacr.caltech.edu
Tue Jul 6 16:13:06 PDT 2004


Hi,

I have posted my stylesheet to convert XML schema (xsi:type based) to
XForms instances on the twiki at:

http://www.ivoa.net/twiki/bin/view/IVOA/IVOARegWp03/xsd2XFm.xsl

I recommend using xsltproc as the stylesheet engine (Saxon will work as
well but does not produce the namespace acronyms). The stylesheet takes
arguments:

--stringparam root <name of root element, e.g. resource>
--stringparam rootType <namespace specified type for root element, e.g.
			'cs:ConeSearch'>
--stringparam targetAction <the argument for the submit button, e.g.
			    'Publish'>
--stringparam substitute <a list of substitutions, e.g. what type do we
really want instead of the the specified abstract type - the syntax is
xx:abstractType1/yy:realType1;xx:abstractType2/yy:realType2...>

So, for example to create a XForms for an all-sky cone search service, the
call would be:

xsltproc --stringparam 'resource' 
	 --stringparam 'cs:ConeSearch' 
         --stringparam targetAction 'Publish' 
         --stringparam substitute 'vr:Interface/vs:ParamHTTP;vs:Region/vs:AllSky'
	 xsd2XFm.xsl ConeSearch-v0.3.xsd > ConeSearch.html

The schema that needs to be specified is that which contains the root
element type; all other schemas required will be imported and processed by
the stylesheet.

This will now fill in default values where it can in the instance part of
the XForms model according to the following prescription:

Default attribute present: use declared default value
Type is xs:float: set to 0.0
Type is xs:int: set to 0
Type is xs:string: set to NULL
Type is xs:boolean: set to true
Type is xs:date: set to 1970-01-01+00:00
Type is an enumeration: set to first value in enumeration
Type is an extension: it will attempt to set it to the correct value
depending on what it is an extension of
Type is vr:IdentifierURI: set to ivo://x.x/

This was all required so that the XForms document produced would be valid
(using Eclipse and Oxygen XML plug-in). Note that you need to include the
location of all the schemas used (with an xsi:schemaLocation) in the
XForms document if you want to validate it.

Now the bad news: whereas the former schema style produced XForms that
worked fine with the formsPlayer plug-in, the new style produces one that
do not. The XForms are valid - the DENG XForms processor displays them
fine but this unfortunately does not yet handle repeat elements (X-Smiles
is also not complete in its support for these). I have submitted a bug
report to formsPlayer to see if they can sort it out.

Please let me know if you have any questions or problems with any of this.

	Cheers,

	Matthew



More information about the registry mailing list