Subject: Re: [xsl] RE: syntax sugar for call-template From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 16 Feb 2001 18:55:05 +0000 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] RE: syntax sugar for call, Uche Ogbuji | Thread | Re: [xsl] RE: syntax sugar for call, Uche Ogbuji |
[xsl] XSLT 2.0 Grouping Use Cases, Steve Muench | Date | Re: [xsl] XSLT 2.0 Grouping Use Cas, David Carlisle |
Month |