xsl-list
[Top] [All Lists]

RE: [xsl] How to handle dynamic XPath

2009-04-14 03:48:38
I am using XSLT to walk through an XML Schema to construct an Xforms
(output) instance.
In parallel I am scanning an (input) instance (of a document 
defined by the schema) to include default values in the form.

Scanning of the input instance is done by means of a variable 
that keeps track of the path. The variable is updated 
(renewed) each time a template is
(recursively) called with the variable as parameter:

You haven't given a great deal of detail about the requirements

However, on the surface, I think my preferred approach here would be to
write a (meta)stylesheet that takes the schema as input and generates an
XSLT stylesheet as output. This latter stylesheet should then expand the
default values in your form.

This approach is more portable than using xx:evaluate(); it is also likely
to be more efficient, more resilient to namespace variations, and more
maintainable.

The other part of your application architecture I would question is the idea
of processing raw schema documents as your input. It's almost impossible in
practice to do this correctly - there are so many different ways that users
can write the same schema, and I bet that you end up testing your code on
only a tiny fraction of these. As an alternative, you might consider using
as input the SCM output available from the Saxon schema processor, which
gives you an XML view of the compiled schema, eliminating all these
variations.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--