[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] user-defined types in something other than Schema?

Subject: RE: [xsl] user-defined types in something other than Schema?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 4 Jan 2005 18:06:40 -0000

> Is it possible to declare user-defined types for 
> XSLT 2.0 with something other than XML Schema?
> As I read http://www.w3.org/TR/xslt20/ , the
> xsl:import-schema statement supports only XML Schema. 

XML Schema defines an abstract model of types, as well as a concrete syntax.
XSLT is dependent on the abstract model, but not on the concrete syntax. The
specification of xsl:import-schema is essentially that you supply a
namespace and a location hint and the system returns a set of type
definitions in that namespace. Implementations are allowed to innovate in
how that works in detail.

Saxon, for example, is starting to map Java classes onto the type system so
that any Java class can be regarded as an XSLT/XPath type. The detail of
this isn't well fleshed out yet, but it can be done.
> For instance, one can't provide an adapter for
> xsl:import-schema statement that implements 
> non-Schema typing such as ooRelaxNG or DTLL.

Yes, I think you can - provided the implementor gives you the right hooks,
and provided you can express the relevant types in terms of the XML Schema
model (e.g. you have to say whether they are simple types or complex types,
what their lexical space and value space is, and so on).
> Would it be conceivable for a DITA implementer 
> to create a DITA adapter for xsl:import-schema 
> that could populate the type annotation based 
> on the DITA class attribute?  Or, could a DITA
> implementer provide templates that add type annotation
> to the tree and declare the type hierarchy prior
> to firing templates that match the tree based
> on the type?

In principle the language is designed to have the architectural flexibility
to allow this. Time will tell whether implementations choose to exploit all
this freedom.
> As a workaround for non-Schema type definitions,
> might one generate a Schema in which each element 
> has the correct type and each type has the correct 
> base type but each type can contain any element or
> attribute?

Certainly one way of coping with any product limitations is to translate the
types you want to use into XML Schema notation.

In Saxon you could in principle construct the schema object model
programmatically. In practice, I don't think I would recommend it, because
the processor doesn't (yet) provide any way to check the consistency of the
model unless it's being built from source schema documents.

If this is a direction you want to explore, however, get in touch off-list.

Michael Kay

Current Thread