Re: [xsl] how to do this

Subject: Re: [xsl] how to do this
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Wed, 5 Nov 2008 14:24:22 +0530
I thought something like ...

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                       version="1.0">

 <xsl:output method="xml" indent="yes" />

 <xsl:template match="node() | @*">
   <xsl:copy>
     <xsl:apply-templates select="node() | @*" />
   </xsl:copy>
 </xsl:template>

 <xsl:template match="AnnouncementOrder">
   <xsl:copy>
     <xsl:copy-of select="node()" />
     <xsl:if test="not(Announcement = 'Elephant')">
       <Announcement>Elephant</Announcement>
     </xsl:if>
     <xsl:if test="not(Announcement = 'Monkey')">
       <Announcement>Monkey</Announcement>
     </xsl:if>
   </xsl:copy>
 </xsl:template>

</xsl:stylesheet>

On Wed, Nov 5, 2008 at 1:17 PM, amit singh <pundir.1984@xxxxxxxxx> wrote:
> Hi Friends ,
>
> I want to change xml given below
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ZooConfiguration
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="..\..\..\schema\Zoo.xsd">
>  <Configuration id="default">
>    <AnnouncementOrder>
>      <Announcement>Donkey</Announcement>
>      <Announcement>Lion</Announcement>
>      <Announcement>Snake</Announcement>
>      <Announcement>Zebra</Announcement>
>    </AnnouncementOrder>
>  </Configuration>
> </ZooConfiguration>
>
>
> Condition is that if any one of (Elephant,Monkey) is there , donot
> change any thing in xml . If none of (Elephant,monkey) present then
> add both (Elephant,monkey) in sequence .
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ZooConfiguration
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="..\..\..\schema\Zoo.xsd">
>  <Configuration id="default">
>    <AnnouncementOrder>
>      <Announcement>Donkey</Announcement>
>      <Announcement>Lion</Announcement>
>      <Announcement>Snake</Announcement>
>      <Announcement>Zebra</Announcement>
>      <Announcement>Elephant</Announcement>
>      <Announcement>Monkey</Announcement>
>    </AnnouncementOrder>
>  </Configuration>
> </ZooConfiguration>
>
> thanks
> Amit singh


-- 
Regards,
Mukul Gandhi

Current Thread