Subject: RE: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan) From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx> Date: Wed, 27 Feb 2008 15:56:56 +0530 |
Thanks Michael for the detailed explanation. Never used "mode" attribute but seems to perfect in my case. One more question, don't you think that <xsl:import> or <xsl:include> (although I still do not know much about these two elements) will be more helpful in this case to avoid the long and complex stylesheet. I would prefer to modularize this rather having a single stylesheet, which later will be painful, if debugging is required. Just wanted to take the opinions before I jump into it and start defining my style sheet. Thanks anyway. Pankaj -----Original Message----- From: Michael Ludwig [mailto:mlu@xxxxxxxxxxxxx] Sent: Wednesday, February 27, 2008 3:27 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan) 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> Confidentiality Notice:" This message and any attachment(s) contained here are information that is confidential, proprietary to IDS Infotech Ltd. and its customers. Contents may be privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer."
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Different conditional out, Michael Ludwig | Thread | Re: [xsl] Different conditional out, Michael Ludwig |
Re: [xsl] Different conditional out, Michael Ludwig | Date | Re: [xsl] Different conditional out, Florent Georges |
Month |