Hi Abel,
Thanks for replying! I am using XSLT-2.0.
I have tried copying the required contents but while doing comparison I
messed up so I am only pasting the code for copying the content. I have
used position() function but it always prints "2" :(
Code is pasted below:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:apply-templates select="document('File1.xml')/*/version"/>
</xsl:copy>
</xsl:template>
<xsl:template match="input00">
<xsl:copy>
<xsl:attribute name="version">
<xsl:value-of select="position()"></xsl:value-of>
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Hope this will help.
BR,
Varun
On Tue, Aug 12, 2014 at 5:45 PM, Abel Braaksma (Exselt) abel@xxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> > I have two files and I am trying to merge them.
>
> Can you show us what you tried so far in XSLT, so that we can help you
> with the explicit issue you are having?
>
> > I want to compare the attribute value of "version" with in the
> > same file, if the values are different I want to copy them in
> > sequential order but if they are same then those attribute
> > should have the same value.
>
> Not quite clear, in your output there are version numbers that do not
> appear in your input. Pairwise merging is easiest in XSLT 3.0 with the new
> xsl:merge instruction, but you didn't say what version of XSLT you are
> using.
>
> One way to tackle your issue, but not necessarily the most economical, is
> to process both files and sort them on version number, then pipeline the
> result and use grouping with group-adjacent. But it depends on your actual
> requirements whether this approach is good enough.
>
> Cheers,
>
> Abel Braaksma
> Exselt Streaming XSLT 3.0 processor
> http://exselt.net
|