xslt, xpath filtering

Hi,

I have the attached xml and I am using Altova stylevision to transorm the xml in html. This tool uses xslt and xpath.

What I cannot figure out how to do is obtain the name attribute of weekday but only for the occurrence with the maximum Revenue.

Your expert advice is most welcome.

Thanks in advance.
myxml.xml
robespierre_2010Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
you can get there by sorting the nodes and pick the first one
    <xsl:template match="DailyData">
        <xsl:for-each select="WeekDay">
            <xsl:sort select="Revenue" data-type="number" order="descending"/>
            <xsl:if test="position() = 1">
                <xsl:copy-of select="."/>
            </xsl:if>
        </xsl:for-each>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
robespierre_2010Author Commented:
Hi,
Thanks for your help.

I am using sort and then position()=1, as you suggested.

However, the field for which I am sorting is giving me sompe the following problem:

The values the field takes are 40.55; 38.23; 78.94; ...; 100

 position()=1 is not retrieving the occurrence with value 100 but the highest occurrence where the value is of type xx.yy which in this case would be 78.94

Is this a problem related to the schema definition? Do you know how to make sure that the evaluation of position()=1 takes into consideration the value of 100?

Regards.
0
Geert BormansInformation ArchitectCommented:
well there are a lot of flaws in the XSLT engines of Altova (they simply suck in my opinion :-)
erroneous sorting is one of the flaws.
If this is XSLT2 there also might be the issue of not implicitely casting to number
so maybe it is a good idea to change the sort like this
            <xsl:sort select="number(Revenue)" data-type="number" order="descending"/>
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

robespierre_2010Author Commented:
this last issue was solved by changing the data type from text to nnumeric in the sort dialog in Altova stylevision.
0
robespierre_2010Author Commented:
thanks a lot
0
robespierre_2010Author Commented:
by the way, what would be your tool of choice if not altova?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.