Altova Mailing List Archives


Re: [xsl] RE: syntax sugar for call-template

From: Jeni Tennison <mail@---------------->
To:
Date: 2/16/2001 9:42:00 AM
Hi Uche,

> introspection is in short the ability to query an object for its
> metadata. For example. An example of metadata of a named template
> might be the parameters it expects. Metadata on a stylesheet might
> be the templates it provides.

Can't you do this already through document('')?  For example, to get a
list of the named templates provided by a stylesheet, you can use:

  document('')/*/xsl:template[@name]

and to get the names of the parameters on a template named 'my:func',
you can use:

  document('')/*/xsl:template[@name = 'my:func']/xsl:param/@name

and so on.

Having said that, this is really limited because it works on the
stylesheet document node tree, not the extended logical structure that
comes with it - you can't use this method to query into the *imported*
and *included* templates (well, you can but it's quite a bit more
complicated).

> Imagine being able to automatically assign items in a node-set to
> the corresponding positional parameters in a template (with position
> being determined by the document order of the with-param elements in
> the template).

I think I know what you mean here - if the node set $list contains two
elements, 'one' and 'two', then something like:

  my:func(expand($list))

will be equivalent to:

  my:func(one, two)

Right? I think that one problem with this is that node sets in XSLT
aren't like arrays in normal programming languages - you can't fix
what order things should be defined in.  Imagine that the nodes that
you wanted to pass as arguments were attributes - you couldn't make
sure that one particular attribute was passed as the first argument
because you don't know what their document order is going to be.

>> I like being able to set parameters by name. It also might lead to
>> interesting situations if you dynamically alter the names of the
>> parameters (they're just strings, after all) [if we had a
>> call-template() function then you could dynamically alter the name
>> of the template too!)
>
> Yes. This allows such useful techniques as delegation, where, say a
> named template could dynamically find and dispatch to another
> template specialized to handle the needed function.

Excellent point.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.