Re: [xsl] keys and idrefs - XSLT2 request?

Subject: Re: [xsl] keys and idrefs - XSLT2 request?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 12 Oct 2001 10:40:05 +0100
Joerg Pietschmann wrote:
> I got the impression that XPath 2.0 is mainly dependent on primitive
> data types assigned to element content or attributes. Hmm, do you
> think it is useful to have some sort of "mode" where the XSLT
> processor decides where a datatype makes a difference in the
> processing of the data, and then loads lazily only the parts of the
> schema which are of interest, without a full validation? I mean, if
> i'm copying stuff i don't care whether it's declared to be a date,
> but i do care if i use it as a sort key. I don't think full
> validation is a good idea if a XML document is served again and
> again via server side XSL, but it might be convenient to have data
> types from the schema available during the transformation for the
> parts where it matters.

Perhaps it will be possible for XSLT processors to optimise a bit, so
that they detect how much validation is actually required by a

But the big difficulty is that the way XML Schema is written, in
particular the ability to define local elements, makes it quite hard
to just validate a portion of a document - you don't know what element
declaration should be used to validate a particular element without
validating right from the start of the document. Compare that with
DTDs, where you only really need to declare the bits that you're
actually interested in, because all the element declarations are

The only thing that really makes that easier is if you have xsi:type
attributes on all the elements, that point explicitly to the type of
the particular element. But perhaps that's a technique that
stylesheets could use too...

I haven't thought this through, but what about a top-level element
that defined the validation that was required by the stylesheet,
something like:

<xsl:validate match="foo/bar/@date" type="xs:date" />
<xsl:validate match="my:baz" type="my:bazType" />

The stylesheet could determine which parts of the source document(s)
need to be validated against which schema types. If you're using
global element declarations, then you could skip the type attribute to
just say 'validate against that matching global element declaration'.
Telling the stylesheet to validate the whole document would just
involve matching the document element:

<xsl:validate match="/*" />

I have no idea whether this would be practical/implementable - what
happens if the type declared in the schema and the type declared in
the stylesheet don't match? would schema validators offer an API that
made it possible to do partial validation? - but something like it
would allow stylesheet authors to focus validation to the level that's
required for a particular stylesheet.

Of course the other possibility would be to have the stylesheet be
able to determine whether to validate or not at a global level, and
then cast the values that you want to be a particular type to that
particular type. I'm not sure how casting would work with user-defined
types, though, or complex types - it's not something covered in the

Just some random thoughts,


Jeni Tennison

 XSL-List info and archive:

Current Thread