Re: [xsl] Suppress and test

Subject: Re: [xsl] Suppress and test
From: Ronan Klyne <ronan.klyne@xxxxxxxxxxx>
Date: Mon, 07 Apr 2008 09:38:10 +0100
Hi Pankaj,

I'd do this with separate templates, and let the processor do the hard work for you, like so:

<xsl:template match="article/meta/journalcode[.='CEDE']">
	<xsl:apply-templates mode="CEDE"/>
</xsl:template>

<xsl:template match="article/meta/journalcode[.='CIJB']">
	<xsl:apply-templates mode="F-chic-auth-date"/>
</xsl:template>

<xsl:template match="article/meta/journalcode">
	<xsl:element name="journalcode">
		<xsl:attribute name="dummy">
			<xsl:value-of select="string(.)"/>
		</xsl:attribute>
		<xsl:copy-of select="@*"/>
	</xsl:element>
</xsl:template>


The journalcode element will only be copied to the output when it's string value is NOT 'CEDE' or 'CIJB'.
Hope that helped...


Ronan


Pankaj Chaturvedi wrote:
Hi,

I've an element <journalcode>CIJB</journalcode>, which I want to suppress
(make an empty element) in my output while also testing its string value to
apply different modes.

I've defined the following but ending up with result <journalcode
dummy="CIJB"/>CIJB<issn ............... (though getting fair result with
testing). I've tried different way around to get the desired output
(<journalcode dummy="CIJB"/>) but doesn't seems to be working. Can I've any
suggestions in this regard. I think I am doing something wrong with
<xsl:apply-templates> here, but not sure.




<xsl:template match="article/meta/journalcode"> <xsl:element name="journalcode"> <xsl:attribute name="dummy"> <xsl:value-of select="string(.)"/> </xsl:attribute> <xsl:copy-of select="@*"/> </xsl:element> <xsl:if test="string(.)='CEDE'"> <xsl:apply-templates mode="CEDE"/> </xsl:if> <xsl:if test="string(.)='CIJB'"> <xsl:apply-templates mode="F-chic-auth-date"/> </xsl:if> </xsl:template>


Best,


Pankaj Chaturvedi

============================================================================
================


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




--
Ronan Klyne
Business Collaborator Developer
Tel: +44 01189 028518
ronan.klyne@xxxxxxxxxxx
www.groupbc.com

Current Thread