[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: dynamically applying templates
Hi Bruce,
At 02:46 PM 9/15/2004, you wrote: .... and add a template to match mods:mods (but notice I pulled the mode, imagining that the "bibliography" mode is to handle nodes in the config document. I don't mean to second-guess your reasoning. I just wanted to be clear that the "bibliography" mode didn't appear to be helping in this particular case. If you need it for some larger reason, fine. (Just make sure it doesn't clash with the traversal of the cs: nodes. Maybe they're the ones that don't need the mode.) That's the template where we'll jump trees, so -- Well, by using a variable or parameter to tweak which reftype is selected. Presumably there will be others, and which one is picked should depend on ... whatever it depends on. In fact, this is the whole "dynamic selection" of your template -- the particular node that's selected should depend on which configuration you want to follow in this instance. Note: I do have a function (again, with Jeni's help) that determines the type of mods record (book, etc.), but I've not thought about whether and how to bring that over to the cs:* stuff. That might be exactly what you want. Say if your input made the reference type explicit, <mods type="book">...</mods>, then the select expression could read select="$style-biblio/cs:entry/cs:reftype[@name=current()/@type] ... thereby choosing whatever reftype matched the type given in the mods input. Your function might be to do exactly this, for all I know. :-> There the type is just a straight attribute value. Yes: in the configuration data the values have to be hardcoded, because presumably they each map to a different reference type -- whatever range of reftypes might be present in the source. <xsl:with-param name="source" select="."/> <!-- this is where we jump to the other tree, carrying the original context with us as the $source --> Well of course in XSLT the context changes with each template match, so yes (except that it's no more "original" than the context you shift to when you match the selected node). The with-param select does not jump you back; what jumps you back is another apply-templates, or more simply a value-of, which calls into $source with an XPath. (The with-param is only necessary to "carry state" as new templates are applied, and may be completely unnecessary if those tunneling parameters work, since that's what they do.) Also, a niggle: any particular reason why your configuration couldn't be I was just curious why you have a "reftype" layer as an element inside the bibliography config structure, since it seems to be providing no information other than the reference type, which could equally well be expressed as a name-value pair on the "entry" parent. The extra wrapper seems just to be getting in the way here. I hope this helps clear things up. Cheers, Wendell
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|