Re: [xsl] Doing math in XSLT?

Subject: Re: [xsl] Doing math in XSLT?
From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 1 Apr 2024 19:58:25 -0000
I found at least one problem which is the substring-after. Not all of my
tables use col as a prefix but use just c. Not sure how that happens as these
are complex tables and I'm sure would have been created in the table
editor.Now exploring regex to just match the digits, but that looks like
analyze-string to do that. I'll have to research further to make sure there
are always digits in the name. May be safer to pull the value from the
collection definition. It looks like if there are no spans the colnum is not
added.Sent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------From: "Dimitre Novatchev
dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 4/1/24
11:49 AM  (GMT-08:00) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl]
Doing math in XSLT? Seems the problem is not in what you have described, but
somewhere else.I cannot reproduce it.When this transformation:<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"B xmlns:xs="http://www.w3.org
/2001/XMLSchema">B <xsl:output omit-xml-declaration="yes" indent="yes"/>B 
<xsl:template match="entry">B  B  <xsl:variable name="vStart" as="xs:double"B 
B  B select="number(substring-after(@namest, 'col'))"/>B  B  B <xsl:value-of
select="$vStart"/>B  </xsl:template></xsl:stylesheet>is applied on the
provided XML document:<row>B  B <entry nameend="col2" namest="col1">B  B 
B <p>OpenID Connect client settings</p>B  B  B <note id="note_N1055C">The
following parameters are only applicableB  B  B  B  B  B  B  B  B  B  B  B 
when this client supports the OpenID Connect useB  B  B  B  B  B  B  B  B  B 
B  B  cases.</note>B  B </entry></row>The wanted/expected/correct result is
produced:1On Mon, Apr 1, 2024 at 11:36b/AM dvint@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:I have the following XML

<row>
B  B  B  B  <entry nameend="col2" namest="col1">
B  B  B  B  B  B  B  B  <p>OpenID Connect client settings</p>
B  B  B  B  B  B  B  B  <note
B  B  B  B  B  B  B  B  B  B  B  B  id="note_N1055C"
B  B  B  B  B  B  B  B  B  B  B  B  >The following parameters are only
applicable
B  B  B  B  B  B  B  B  B  B  B  B  when this client supports the OpenID
Connect use
B  B  B  B  B  B  B  B  B  B  B  B  cases.</note>
B  B  B  B  </entry>
</row>

The attributes nameend="col2" namest="col1" indicate that this row spans
2 columns (end - start + 1).

I've tried this to try and get the numbers 1 and 2 from these strings,
but I get NaN errors

<xsl:variable name="start"
B  B  B  B  select="number(substring-after(@namest, 'col'))" as="xs:double"/>
<xsl:variable name="end"
B  B  B  B  select="number(substring-after(@nameend, 'col'))"
as="xs:double"/>

I've tried this in different combinations with/without the
as="xs:double" and number() and those variations throw the same error.

The table itself has this information

<table colsep="0" frame="none" id="table_post_oauthClients_endpoints"
B  B  B  B  rowsep="0">
B  B  B  B  <tgroup align="left" cols="2">
B  B  B  B  B  B  B  B  <colspec colname="col1" colnum="1" colwidth="1*"/>
B  B  B  B  B  B  B  B  <colspec colname="col2" colnum="2" colwidth="3*"/>
B  B  B  B  B  B  B  B  <thead>
B  B  B  B  B  B  B  B  B  B  B  B  <row>
B  B  B  B  B  B  B  B  B  B  B  B  B  B  B  B  <entry
colname="col1">Parameter</entry>
B  B  B  B  B  B  B  B  B  B  B  B  B  B  B  B  <entry
colname="col2">Description</entry>
B  B  B  B  B  B  B  B  B  B  B  B  </row>
B  B  B  B  B  B  B  B  </thead>

I'll try referencing the <colspec> element and using the @column value,
but that seems like it will give me the same issue.

..dan


-- Cheers,Dimitre Novatchev---------------------------------------Truly great
madness cannot be achieved without significant
intelligence.---------------------------------------To invent, you need a good
imagination and a pile of junk-------------------------------------Never fight
an inanimate object-------------------------------------To avoid situations in
which you might make mistakes may be thebiggest mistake of
all------------------------------------Quality means doing it right when no
one is looking.-------------------------------------You've achieved success in
your field when you don't know whether what you're doing is work or
play-------------------------------------To achieve the impossible dream, try
going to sleep.-------------------------------------Facts do not cease to
exist because they are ignored.-------------------------------------Typing
monkeys will write all Shakespeare's works in 200yrs.Will they write all
patents, too? :)-------------------------------------Sanity is madness put to
good use.-------------------------------------I finally figured out the only
reason to be alive is to enjoy it.B 



XSL-List info and archive

EasyUnsubscribe
(by email)

Current Thread