I have to ask this question here...
Added by Anonymous over 19 years ago
Legacy ID: #3015008 Legacy Poster: Curtis (cdfisher07)
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: <RPM> 30.06 40.05 50.07 60.07 70.08 80.12 99.1 100 </RPM> I am attempting to find the largest number and as Dr. Kay pointed out on another forum, using... <xsl:variable name="rpm" select="max( for $i in tokenize($data/DataFile/RunData/RPM/text(),'\r?\n') return number($i) )"/> <xsl:value-of select="$rpm"/> will return the largest number. However I get NaN returned. It will work if the data is arranged as such: <RPM>30.06 40.05 50.07 60.07 70.08 80.12 99.1 100</RPM> 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 and bottom. 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. Curtis Fisher
Replies (2)
RE: I have to ask this question here...
-
Added by Anonymous over 19 years ago
Legacy ID: #3015464 Legacy Poster: Michael Kay (mhkay)
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. Michael Kay
RE: I have to ask this question here...
-
Added by Anonymous over 19 years ago
Legacy ID: #3016311 Legacy Poster: Curtis (cdfisher07)
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! Sincerely, Curtis Fisher
Please register to reply