Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2008, 03:40 AM
Authorized User
 
Join Date: Jul 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Different conditional outputs in same Stylesheet

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>.

See the reference part:
<article>
<meta>
<journalcode>CEDE</journalcode>
<issn type="print">XXXX-XXXX</issn>
</meta>
<references>
<ref-book id="CIT0001">
<authorfield>
<author-ref>
<surname>Bergstrom</surname><givenname>T.C.</givenname>
</author-ref></authorfield>
<chaptitle>xxxxx</chaptitle> <booktitle>yyyyyyy</booktitle>
<publicationfield>
<pubname>uuuu</pubname>
<pubplace><city>Amsterdam</city></pubplace>
<year>1997</year><volumenum>1A</volumenum></publicationfield>
<pagefield>
<firstpage/>
</pagefield>
</ref-book>
</references>
</article>

Reference part needs to be (just an example):
<ref-book id="CIT0001">
<authorfield>
<author-ref>
<givenname>T.C.</givenname><surname>Bergstrom</surname>
</author-ref></authorfield>, <year>1997</year>.
<chaptitle>xxxxx</chaptitle>, In:<booktitle>yyyyyyy</booktitle>
<publicationfield>
<pubname>uuuu</pubname>
<pubplace><city>Amsterdam</city></pubplace>
<volumenum>1A</volumenum></publicationfield>
<pagefield>
<firstpage/>
</pagefield>
</ref-book>
(See the punctuation and appearance of <year>).

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.

Earlier I used to do it with one of the composition platform which supports loading the namespaces but right now I would prefer to do t with Stylesheet.

Any suggestions in this regard will highly appreciated.

PS: I am using XSLT version "1.0" and currently going thru the Michael Kay's Programmer's Reference book. May be some body can suggest where I need into (I mean topics) to get this done.

I hope I've made myself clear!!!



Pankaj
__________________
Pankaj
 
Old February 23rd, 2008, 04:06 AM
Authorized User
 
Join Date: Jul 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I've been just going thru the book and I guess I need to look into the <xsl:import> element. This means I need to write separate stylesheets and later call them in main one.

Any suggestions.


Pankaj
 
Old February 23rd, 2008, 09:17 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I am not sure I understand what you are asking about but it sounds to me as if you want to author different templates based on the journalcode e.g.
Code:
<xsl:template match="article[meta/journalcode = 'CEDE']">

</xsl:template>

<xsl:template match="article[meta/journalcode = 'FOO']">

</xsl:template>
 
Old February 26th, 2008, 02:25 AM
Authorized User
 
Join Date: Jul 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You got me correctly, I am in fact looking for conditional outputs depending upon journal code.

But instead of using

<xsl:template match="article[meta/journalcode = 'CEDE']">

</xsl:template>

I would prefer to call may be another stylesheet which will be dealing references in different-different manners as there are n numbers of outputs are required.

Something like below:

<xsl:template match="article[meta/journalcode = 'CEDE']">

</xsl:template>

This is also something modularizing the stylesheets (call another stylesheet from one).

I was fiddling thru the book and I think I need to look into <xsl:import> or <xsl:include> elements.


Any suggestions.



Pankaj





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Stylesheet on Reports murali.tk BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 April 17th, 2006 09:47 PM
CSS 2 Stylesheet jainnid CSS Cascading Style Sheets 1 July 6th, 2005 01:16 AM
i need help with css stylesheet DSteven CSS Cascading Style Sheets 2 February 13th, 2005 02:10 PM
Stylesheet load problems ravirao Apache Tomcat 1 August 3rd, 2004 12:58 AM
My stylesheet treat!! freezotic BOOK: Beginning Java 2 1 March 26th, 2004 04:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.