Hello,
I have this xml file.
and I would like to convert it in other xml file, where I need to add a new row with the value of max between Val1 and Val2:
how can I do it?
Thanks
I would suggest using StackOverflow for general XSLT coding questions - there’s a wider group of people answering questions on that forum, and this is nothing specifically to do with Saxon.
On 17 Jun 2015, at 16:53, Raul Iturbe luarit@users.sf.net wrote: Hello, I have this xml file. <racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine> and I would like to convert it in other xml file, where I need to add a new row with the value of max between Val1 and Val2: <racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="MaxVal1ORVal2">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine> how can I do it? It’s hard to say without knowing what other input documents your code might have to deal with, but perhaps something like this:
On 17 Jun 2015, at 16:53, Raul Iturbe luarit@users.sf.net wrote:
<racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine>
<racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="MaxVal1ORVal2">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine>
It’s hard to say without knowing what other input documents your code might have to deal with, but perhaps something like this:
<xsl;template match="“arrêté”"> <xsl:copy-of select="“ValeurIndex<span">[@Libelle=‘Val1’]”/> <ValeurIndex Libelle="“MaxVal1ORVal2”"> <xsl:value-of select="“max(ValeurIndex<span">[@Libelle=(‘Val1’, ‘Val2’)])”/> </ValeurIndex> <xsl:copy-of select="“ValeurIndex<span">[@Libelle=‘Val2’]”/> etc. </xsl:template>
Michael Kay Saxonica
Hello,
I have this xml file.
<racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine>and I would like to convert it in other xml file, where I need to add a new row with the value of max between Val1 and Val2:
<racine> <index> <Parent nom="00000002" Name="" Address=""/> <Meter numSerie="00000002"/> <arrêté dateArrêté="28/02/2015 00:00:00"> <ValeurIndex Libelle="Val1">23.334</ValeurIndex> <ValeurIndex Libelle="MaxVal1ORVal2">23.334</ValeurIndex> <ValeurIndex Libelle="Val2">5.186</ValeurIndex> <ValeurIndex Libelle="Val3">2.79</ValeurIndex> </arrêté> </index> </racine>how can I do it?
Thanks
I would suggest using StackOverflow for general XSLT coding questions - there’s a wider group of people answering questions on that forum, and this is nothing specifically to do with Saxon.
<xsl;template match="“arrêté”">
<xsl:copy-of select="“ValeurIndex<span">[@Libelle=‘Val1’]”/>
<ValeurIndex Libelle="“MaxVal1ORVal2”">
<xsl:value-of select="“max(ValeurIndex<span">[@Libelle=(‘Val1’, ‘Val2’)])”/>
</ValeurIndex>
<xsl:copy-of select="“ValeurIndex<span">[@Libelle=‘Val2’]”/>
etc.
</xsl:template>
Michael Kay
Saxonica