Re: [xsl] Comparing attributes and setting the values

Subject: Re: [xsl] Comparing attributes and setting the values
From: "Michael Müller-Hillebrand mmh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Aug 2014 18:48:42 -0000
Varun,

It would be more along this:

   <xsl:template match="/">
    	<xsl:variable name="union">
                <xsl:apply-templates select="//Item" mode="step1" />
                <xsl:apply-templates select="document('File2.xml')/*//Item"
mode="step1" />
   	</xsl:variable>
        <A>
            <target>
                <xsl:apply-templates select="$union/*" />
            </target>
        </A>
    </xsl:template>

with a special template for that mode "step1":

<xsl:template match="Item" mode="step1">
   <xsl:copy-of select="." />
</xsl:template>

This way you would collect all <Item> in variable $union in their own, common
tree and then you can expect to have the correct context for preceding
elements.

If you are on a tight timeline and the task is above your current knowledge
level you might consider seeking professional help. You should at a minimum
make yourself familiar with the concept of trees, which is required to
understand the axis.

HTH,

- Michael



Am 21.08.2014 um 11:28 schrieb varun bhatnagar varun292006@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>:

> Hi,
> To join all the Item elements I tried using copy and copy-to elements of xsl
and then I applied the template rules but it did not work.
>
>  <xsl:template match="/">
>          <A>
>             <target>
> <xsl:copy>
>                  <xsl:apply-templates select="//Item"/>
>                  <xsl:apply-templates
select="document('File2.xml')/*//Item"/>
> </xsl:copy>
>              </target>
>          </A>
>      </xsl:template>
>
> Is this the correct way of doing it? Could anyone please help, I am not able
to proceed :(
>
> Thanks,
> BR,
> Varun

Current Thread