xsl-list
[Top] [All Lists]

Re: [xsl] Comparing attributes and setting the values

2014-08-21 13:48:54
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(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>:

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

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>