xsl-list
[Top] [All Lists]

Re: [xsl] Comparing attributes and setting the values

2014-08-22 04:31:52
Hi Michael,

Thank you so much for replying.
Yes, I have a deadline :(  and I have been reading a lot of xslt stuff
available on the internet, going through ebooks and online tutorials but I
still have little bit of confusion about xslt tree creation.
I have tried your suggestion out but my xslt processor throws an error. It
is not able to process the stylesheet because of apply-templates part where
you have passed the variable.
<A>
            <target>
                <xsl:apply-templates select="$union/*" />
            </target>
        </A>

And if I try to pass it using <value-of> element then it prints the text
nodes.
Any idea how to fix this?

Thanks,
BR,
Varun


On Thu, Aug 21, 2014 at 8:49 PM, Michael Müller-Hillebrand 
mmh(_at_)docufy(_dot_)de <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

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 <-list/2562907> (by
email <>)

--~----------------------------------------------------------------
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>