Subject: Re: [xsl] dynamically applying templates From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx> Date: Tue, 14 Sep 2004 14:45:52 -0400 |
<xsl:template match="cs:reftype"> <xsl:param name="source"/> <xsl:apply-templates> <xsl:with-param name="source" select="."/>
In this case, what exactly is the parameter doing? Are you using this precisely to do the, as you later say, "jumping back and forth between the trees"? So here you're apply-templates to the cs:* elements, and elsewhere to mods:*?
Yes. I'm matching a node in your configuration (the reftype), since its organization and content will drive processing.
But I'm passing a reference back to the mods source so that it can be "jumped back to" anytime I need its data.
This way, not only the content, but also the structure of your cs:reftype can drive processing, without fancy tests.
</xsl:apply-templates> </xsl:template>
<xsl:template match="cs:title"> <xsl:param name="source"/> <!-- do your title thing here, grabbing data from $source (the mods source) as necessary --> </xsl:template>
Here's I'm confused on the $source reference. Does this suggest I am using the source param and doing something like so?
<xsl:template match="cs:title"> <xsl:param name="source"/> <!-- do your title thing here, grabbing data from $source (the mods source) as necessary --> <xsl:apply-templates select="mods:titleInfo"> <xsl:with-param name="source" select="mods:mods"/> </xsl:apply-templates> </xsl:template>
Presumably that would have to be
<xsl:apply-templates select="$source/mods:titleInfo"/>
(And since here you're jumping back to the node in the source tree, you don't need to pass a parameter back -- certainly not one that binds a non-existent mods:mods child of the cs:title context node.)
Sorry, but I feel like a blind man here, and I need to understand it better before I get farther.
It's a pretty sophisticated application of the XSLT processing model on two documents in tandem, so it's not easy to understand.
You have to start by assimilating the processing model itself, including the notions of context nodes, relative paths (including the default child:: axis), and template traversal. If your brain can't track what's happening as the processor traverses a single document, it's probably going to freeze up completely when you try to conceive of traversing two documents back-and-forth. But you have chosen to address a very ambitious requirement.
I'm suggesting, in effect, that you 'push' it from your configuration file.
==== xsl ==== <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:db="http://docbook.org/docbook-ng" xmlns:mods="http://www.loc.gov/mods/v3" xmlns="http://www.w3.org/1999/xhtml" xmlns:bib="http://xbiblio.sourceforge.net/xbib" xmlns:cs="http://xbiblio.sourceforge.net/xcs" exclude-result-prefixes="mods db bib xs cs">
<!-- read the external citation style file --> <xsl:param name="citation-style" required="yes" as="xs:string" />
<xsl:variable name="styles" as="document-node()" select="doc(concat($citation-style, '.csl'))" />
<xsl:template match="cs:title"> <xsl:param name="source"/> <!-- do your title thing here, grabbing data from $source (the mods source) as necessary --> <xsl:apply-templates select="$source/mods:titleInfo" mode="bib"/> </xsl:template>
<xsl:template match="mods:titleInfo" mode="bib"> <span class="title"> <xsl:apply-templates select="mods:title"/> <xsl:apply-templates select="mods:subTitle"/> </span> </xsl:template>
<xsl:template match="cs:creator" mode="bib"> <xsl:param name="source"/> <xsl:apply-templates select="$source/mods:name" mode="bib"/> </xsl:template>
<xsl:template match="mods:name" mode="bib"> <span class="creator"> <xsl:apply-templates select="mods:name"/> </span> </xsl:template>
==== config ==== <citationstyle xmlns="http://xbiblio.sourceforge.net/xcs"> <content> <bibliography author-as-sort-order="yes"> <entry> <reftype name="book"> <title font-style="italic" after=", "/> <creator/> </reftype> </entry> </bibliography> </content> <citationstyle>
<doc> <!-- this would normally be docbook ng; but keep it simple for now --> <mods xmlns="http://www.loc.gov/mods/v3"> <name type="personal"> <namePart type="given">Jane</namePart> <namePart type="family">Doe</namePart> </name> <titleInfo> <title>Main Title</title> <subTitle>Subtitle</subTitle> </titleInfo> </mods> </doc>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dynamically applying temp, Wendell Piez | Thread | Re: [xsl] dynamically applying temp, Wendell Piez |
RE: [xsl] limit number of row retur, Tham Tinh | Date | RE: [xsl] Namespace problem, david_n_bertoni |
Month |