Pankaj Chaturvedi schrieb:
Hi all,
I am writing a stylesheets for different journal (basically for
print), wherein the order of authors, titles etc varies (<ref-book>
here)depending upon the <journalcode>.
[...]
Manipulating data, adding issue is not seems to be problem to me and I
can very much do that, while checking the <journalcode> string with
the use of XSLT, but I am little bit stuck with Idea how to do it in
best way.
I have hundreds of journals for which I am developing stylesheet and
they are very much same till the reference part and the only which
differentiate them is reference style (which are 4 or 5 in count).
Somebody, from publishing industry will definitely understand this
:-).
Anyways, Is there any way I can do it with in same style sheet with
conditionally checking the <journalcode>, instead of defining the . I
am new in XSLT but I am OK with XPath, so I believe I can do this.
You may detect the different journal codes using simple tests and then
branch into different modes to process accordingly.
I don't know if this is the best approach. Its viability may depend
on how much reshaping is required for your different journal codes.
Michael
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="article[ .//journalcode = 'CEDE' ]">
<xsl:comment>CEDE</xsl:comment>
<xsl:copy>
<xsl:apply-templates mode="CEDE"/>
</xsl:copy>
</xsl:template>
<xsl:template match="article[ .//journalcode = 'EHEF' ]">
<xsl:comment>EHEF</xsl:comment>
<xsl:copy>
<xsl:apply-templates mode="EHEF"/>
</xsl:copy>
</xsl:template>
<!-- join authorfield, year, chaptitle, booktitle -->
<xsl:template match="ref-book" mode="CEDE">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="authorfield"/>
<xsl:text>, </xsl:text>
<xsl:apply-templates select=".//year"/>
<xsl:text>. </xsl:text>
<xsl:apply-templates select="chaptitle"/>
<xsl:text>, In: </xsl:text>
<xsl:apply-templates select="booktitle"/>
<xsl:apply-templates mode="CEDE"/>
</xsl:copy>
</xsl:template>
<!-- omit these -->
<xsl:template match="authorfield | year | chaptitle | booktitle"
mode="CEDE"/>
<!-- do special stuff for EHEF -->
<!-- ... -->
<!-- Maybe sufficient for all journal codes? -->
<xsl:template match="author-ref">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="givenname"/>
<xsl:apply-templates select="surname"/>
</xsl:copy>
</xsl:template>
<!-- an identity template for each mode -->
<xsl:template match="@*|node()" mode="EHEF">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="EHEF"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()" mode="CEDE">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="CEDE"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
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>
--~--