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

RE: Conditional statements in XSLT

Subject: RE: Conditional statements in XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 24 Mar 2006 19:42:32 -0000
xslt conditional statement
It seems that under PARAMETERS, you want to copy either the FILE that was
under PARAMETERS in the input, or the FILE that was under OUTPUT in the
input, whichever comes last. So change your /RESULT/PARAMETERS template to:

<xsl:template match="PARAMETERS">
        <xsl:copy>
        <xsl:apply-templates
select="*[not(self::FILE)][not(self::FILENAME)]"/>
        <xsl:copy-of select="(FILE | /RESULT/OUTPUT/FILE)[last()]" />
        <xsl:copy-of select="(FILENAME | /RESULT/OUTPUT/FILENAME)[last()]"
/>
        <xsl:copy>
</xsl:template>

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Higino Silva [mailto:hssilva@xxxxxx]
> Sent: 24 March 2006 17:32
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Conditional statements in XSLT
>
> Hi all,
>
> I'm using Xalan J XSLT processor, version 2.7.0, and though I
> don't have a particular problem with the implementation of
> Xalan I'm having trouble implementing one of the requirements
> for our project,  I'm even not sure if is at all possible to
> do it applying only XSL transformations.
> Can anyone advise me on this one?
> ******* Problem Description: ***********
> I have the following input xml document:
> <RESULT>
>   <PARAMETERS>
>     <CYCLE>
>       <ENDDATE>20060215</ENDDATE>
>     </CYCLE>
>     <FILE><CHECK/></FILE>
>   </PARAMETERS>
>   <OUTPUT>
>     <FILE>b</FILE>
>     <FILENAME>E:\ftphome\vodafone\xml\CC20060215S50.XML</FILENAME>
>   </OUTPUT>
> </RESULT>
>
> Now, the resulting xml should have the FILE and FILENAME tags
> belonging to OUTPUT element transferred to PARAMETERS
> element, which I can do with no effort at all with the
> following template:
> <--! Coy input node to the output -->
> <xsl:template match="*">
>        <xsl:copy>
>        <xsl:apply-templates />
> </xsl:copy>
> </xsl:template>
> <xsl:template match="OUTPUT"></xsl:template> <!--Output node
> is not copied to output -->
> <--! Copy output nodes to Parameters element -->
> <xsl:template match="/RESULT/PARAMETERS">
>        <xsl:copy>
>        <xsl:copy-of select="/RESULT/OUTPUT/*" />
>        <xsl:apply-templates />
>        <xsl:copy>
> </xsl:template>
>
> The tricky thing here is that if the FILE/FILENAME tag (or
> any tag under OUTPUT) exists under PARAMETERS, then the tag
> under PARAMETERS should be overwritten by correspondent
> OUTPUT tag. In this case the correct output should be the following:
> <RESULT>
>   <PARAMETERS>
>     <CYCLE>
>       <ENDDATE>20060215</ENDDATE>
>     </CYCLE>
>    <FILE>b</FILE>
>    <FILENAME>E:\ftphome\vodafone\xml\CC20060215S50.XML</FILENAME>
>   </PARAMETERS>
> </RESULT>
>
> I would much appreciate some help,.
>
> Many many thanks
> Higino Silva
>
>
>
> AVISO
>
> Esta mensagem e quaisquer anexos seus podem conter informagco
> confidencial para uso exclusivo do destinatario. Cabe ao
> destinatario assegurar a verificagco de vmrus e outras
> medidas que assegurem que esta mensagem nco afecta os seus
> sistemas. Se nco for o destinatario, nco devera usar,
> distribuir ou copiar este e-mail, devendo proceder ` sua
> eliminagco e informar o emissor. I estritamente proibido o
> uso, a distribuigco, a cspia ou qualquer forma de
> disseminagco nco autorizada deste e-mail e seus anexos. Obrigado.
>
> DISCLAIMER
> This e-mail and its attachments may contain confidential
> information for exclusive use of its recipient. It is your
> responsibility to carry out appropriate virus and other
> checks to ensure that this message and any attachments do not
> affect your systems / data. If you are not the intended
> recipient you must not use, distribute or reproduce this
> e-mail and you must notify the sender and delete the entire
> email. Any unauthorized use, dissemination, distribution or
> copying of this message and its attachments is strictly
> prohibited. Thank You.

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-2013 All Rights Reserved.