[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Different conditional outputs in same Stylesheet o

Subject: Re: Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan)
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Wed, 27 Feb 2008 10:57:21 +0100
Re:  Different conditional outputs in same Stylesheet o
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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.