[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Comparing xslt attributes and putting them in seq

Subject: Re: Comparing xslt attributes and putting them in sequential order
From: "varun bhatnagar varun292006@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 13 Aug 2014 07:27:57 -0000
Re:  Comparing xslt attributes and putting them in  seq
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.