Dr. Kay, I know you want mulberry to handle XSLT questions, but I cannot get on the list because the US gov. has an entire server blocked that they use. This is a modern forum and the mulberry list is email, so it is not allowed. If there is another forum with a message board such as this then I will be glad to join it.
Here is the latest post I tried to get through with:
It is a continuation of the same problem I have been struggling with. Your explanation helped me to solve it.
I have an element set in my XML document:
I am attempting to find the largest number and as Dr. Kay pointed out on another
<xsl:variable name="rpm" select="max( for $i in tokenize($data/DataFile/RunData/RPM/text(),'\r?\n')
return number($i) )"/>
will return the largest number. However I get NaN returned.
It will work if the data is arranged as such:
Thus, removing the line feeds and new lines at the top and bottom returns 100 instead
of NaN (which is what I get because the tokenize creates 2 extra nodes at the top
My question is this: How can I create a node set from the above without tokenizing
that is passed to the max() function (I think it needs the format max("1,2,3")) and
will return what I need? Do I use the document function?
There is another way to do this (as demonstrated in Sal Mangano's XSLT Cookbook)
but I am trying to use 2.0 features.
Thanks ahead of time.
I guess this isn't the worst restriction of personal liberty that the US government has imposed in the name of security, so I sympathise with your problems.
Your simplest solution is to apply normalize-space() to the list before you tokenize it. This will get rid of the leading and trailing separators, it also means you can use the simpler regular expression "\s".
An even better solution would be to use schema-aware stylesheet processing. If your source document were validated against a schema that described the content of RPM as a list-of-xs:decimal values, then you could simply write max($data/DataFile/RunData/RPM) and the system would already know what data type and tokenization rules to use.
Thank you for your help, a very simple solution and proof that I was getting so wrapped up in the trees, I forgot to look around the forest!
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.