RE: [xsl] request validation of the input document from within the XSLT stylesheet

Subject: RE: [xsl] request validation of the input document from within the XSLT stylesheet
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 May 2006 10:08:56 +0100
It's a good question and I'm having trouble recalling exactly what the
arguments were. I think it might have been one of those cases where we tried
to do something very elaborate, couldn't come up with something that worked,
and ending up doing nothing. We certainly spent a lot of time toying with
ideas such as an <xsl:input> element. One of the objections, I think, was
that we shouldn't provide a lot of capability for the "principal input
document" that wasn't also available for secondary inputs: at one time we
tried to get rid of the concept of a principal input document entirely (it
was only really the problem of global variables that made us keep it.) 

Also, there are probably people who think in terms of the validation phase
as being very closely associated with XML parsing (especially companies
whose products are structured that way).

Of course you can request validation by doing

<xsl:variable name="validated-input">
  <xsl:copy-of select="/" validation="strict"/>

but that might not be efficient.

I'm certainly finding, as you observe, that it's necessary to keep
information in test catalogues and the like about what the stylesheet's
expectations are. Of course, one could put that information in a
user-defined top-level element in the stylesheet itself. Perhaps there's
scope for a Saxon extension in that area. Of course the other way you can
solve the problem in Saxon is to read the document using a URI such as

Michael Kay 

> -----Original Message-----
> From: alan.painter@xxxxxxxxx [mailto:alan.painter@xxxxxxxxx] 
> Sent: 05 May 2006 09:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] request validation of the input document from 
> within the XSLT stylesheet
> I'm surprised to discover that source document validation 
> cannot be directly requested from within the stylesheet in 
> the same manner as the output documents.
> From Michael Kay's book (3rd edition) I find at the top of page 60:
> "You don't request validation of the input document from 
> within the stylesheet.  It's assumed that you will request 
> this as part of the way you invoke the transformation."
> Checking the most recent XSLT2.0 specs (RC) would seem to 
> confirm this.
> What surprises me is that some stylesheets will only work if 
> the input document has type annotations and as such 
> validation of the input document is a requirement.  Since 
> this validation cannot be requested from within the 
> stylesheet, some external information must be kept to signal 
> to the invoking process that validation is to be performed, 
> meaning that pipeline processors and such will need to keep 
> track of that when they perform a transformation.
> I'd be curious to hear why what seems to me to be of obvious 
> utility was not included in the specification.
> -alan
> **************************************************************
> ***********
> This message and any attachments (the "message") are 
> confidential and intended solely for the addressee(s).
> Any unauthorised use or dissemination is prohibited. E-mails 
> are susceptible to alteration.   
> Neither SOCIETE GENERALE nor any of its subsidiaries or 
> affiliates shall be liable for the message if altered, 
> changed or falsified.
>                               ************ Ce message et 
> toutes les pieces jointes (ci-apres le "message") sont 
> confidentiels et etablis a l'intention exclusive de ses 
> destinataires. Toute utilisation ou diffusion non autorisee 
> est interdite. Tout message electronique est susceptible 
> d'alteration. 
> La SOCIETE GENERALE et ses filiales declinent toute 
> responsabilite au titre de ce message s'il a ete altere, 
> deforme ou falsifie.
> **************************************************************
> ***********

Current Thread