Re: [xsl] xml to svg graphs

Subject: Re: [xsl] xml to svg graphs
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Jan 2026 14:35:35 -0000
Why not use fn:abs() which has been there since XPath 2.0?

Michael Kay

> On 28 Jan 2026, at 14:25, David Carlisle d.p.carlisle@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> This works on the one example I tried
>
> saxon10 examples/gr1.xml use_msgr2svg.xsl
>
>
> It just uses the built in math namespace, renames power ot pow (so it works0
and adds a definition of abs (to the`m` namespace, as it was there)
>
>
>
> 8,9c8
> < xmlns:math="http://exslt.org/math";
> < extension-element-prefixes="math"
> ---
> > xmlns:math="http://www.w3.org/2005/xpath-functions/math";
> 769c768
> < m:Log10(if ((.) != 0) then math:abs(.) else 1) else (.)"/>
> ---
> > m:Log10(if ((.) != 0) then m:abs(.) else 1) else (.)"/>
> 874c873
> < <xsl:value-of select="concat('a', math:abs($dx), ',', $hg, ' 0 0,', $sp, '
', 2*$dx, ',0')"/>
> ---
> > <xsl:value-of select="concat('a', m:abs($dx), ',', $hg, ' 0 0,', $sp, ' ',
2*$dx, ',0')"/>
> 1037c1036
> < <xsl:variable name="cif" select="$ps div math:power(10, $rad)"/>
> ---
> > <xsl:variable name="cif" select="$ps div math:pow(10, $rad)"/>
> 1043c1042
> < <xsl:value-of select="$st * math:power(10, $rad)"/>
> ---
> > <xsl:value-of select="$st * math:pow(10, $rad)"/>
> 1054c1053
> < <xsl:value-of select="$pom * math:power(10, $rad)"/-->
> ---
> > <xsl:value-of select="$pom * math:pow(10, $rad)"/-->
> 1063c1062
> < <xsl:variable name="pom" select="round($val * math:power(10, - $rad +1)) *
math:power(10, $rad - 1)"/>
> ---
> > <xsl:variable name="pom" select="round($val * math:pow(10, - $rad +1)) *
math:pow(10, $rad - 1)"/>
> 1078a1078,1082
> >
> > <xsl:function name="m:abs">
> >  <xsl:param name="val"/>
> >  <xsl:sequence select="if($val &lt; 0) then -$val else $val"/>
> > </xsl:function>
>
>
> On Wed, 28 Jan 2026 at 14:16, Martynas JuseviD
ius martynas@xxxxxxxxxxxxx
<mailto:martynas@xxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>> OK, then I misunderstood what you meant with "graphs" :) My bad, ignore my
links...
>>
>> On Wed, Jan 28, 2026 at 3:13b/PM Dave Pawson dave.pawson@xxxxxxxxx
<mailto:dave.pawson@xxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>>> Sorry, my data is far from a directed graph.
>>>   This is one I did get to work, a simple block graph.
>>>
>>> regards
>>>
>>> On Wed, 28 Jan 2026 at 14:09, Martynas JuseviD
ius martynas@xxxxxxxxxxxxx
<mailto:martynas@xxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>>>> Well, the advantage of RDF is that it's a standard :)
>>>> https://www.w3.org/TR/rdf11-primer/
>>>>
>>>> The downside is that its XML-based format (RDF/XML) is rather
convoluted.
>>>>
>>>> But you don't need to write RDF/XML by hand - you can use Jena's CLI to
transform from a more human-readable Turtle format to RDF/XML.
>>>>
>>>> Or heck, I think you could give your names/values data to an LLM and ask
it to produce an RDF equivalent :)
>>>>
>>>> On Wed, Jan 28, 2026 at 3:05b/PM Dave Pawson dave.pawson@xxxxxxxxx
<mailto:dave.pawson@xxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>>>>> Hi Martynas.
>>>>>   The simplicity (and coverage) of Jakobs was ( for me) its advantage?
>>>>>   Two simple lists
>>>>> <names/>
>>>>> <values/>
>>>>>   with a whole host of variants.
>>>>>   Not the same 'graphs' as RDF?
>>>>>
>>>>> regards
>>>>>
>>>>> On Wed, 28 Jan 2026 at 13:56, Martynas JuseviD
ius
martynas@xxxxxxxxxxxxx <mailto:martynas@xxxxxxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>>>>>> Hey Dave,
>>>>>>
>>>>>> Not a direct replacement, but FWIW I have a stylesheet that transforms
RDF graphs (via the RDF/XML format) to force-directed SVG layouts:
>>>>>>
https://github.com/AtomGraph/Web-Client/blob/master/src/main/webapp/static/co
m/atomgraph/client/xsl/converters/RDFXML2SVG.xsl
>>>>>>
>>>>>> The RDF/XML structure might be specific to "normalised" Jena's RDF/XML
output (can't exactly recall now).
>>>>>> https://jena.apache.org/documentation/tools/#riot-and-related
>>>>>>
>>>>>> Martynas
>>>>>> atomgraph.com <http://atomgraph.com/>
>>>>>> On Wed, Jan 28, 2026 at 2:48b/PM Dave Pawson dave.pawson@xxxxxxxxx
<mailto:dave.pawson@xxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
>>>>>>> A long time ago...
>>>>>>>   Jakob wrote some code, now resident (rotting?)
>>>>>>> on Google code.
>>>>>>> https://code.google.com/archive/p/graph2svg/downloads
>>>>>>>
>>>>>>> At the time he use fxsl and exsl for the math(s).
>>>>>>>
>>>>>>> IMHO this is well worth bringing up to date.
>>>>>>> I asked Jakob and received no reply.
>>>>>>>
>>>>>>> Saxon math 'extension' only lacks abs,  from
>>>>>>> my early trials?
>>>>>>>
>>>>>>> If anyone with a mathematical bent has time
>>>>>>> to do the xslt world a favour, I would certainly
>>>>>>> appreciate it.
>>>>>>>
>>>>>>> regards
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Dave Pawson
>>>>>>> XSLT XSL-FO FAQ.
>>>>>>> Docbook FAQ.
>>>>>>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>>>>>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3206323>
(by email <>)
>>>>>>
>>>>>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>>>>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2607481>
(by email <>)
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dave Pawson
>>>>> XSLT XSL-FO FAQ.
>>>>> Docbook FAQ.
>>>>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>>>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3206323>
(by email <>)
>>>>
>>>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2607481>
(by email <>)
>>>
>>>
>>>
>>> --
>>> Dave Pawson
>>> XSLT XSL-FO FAQ.
>>> Docbook FAQ.
>>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3206323> (by
email <>)
>>
>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2739265> (by
email <>)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3500899> (by
email <>)

Current Thread