Google Answers Logo
View Question
 
Q: Need someone with XSLT knowledge to give relatively simple advice (yes/no Qustn) ( Answered 5 out of 5 stars,   2 Comments )
Question  
Subject: Need someone with XSLT knowledge to give relatively simple advice (yes/no Qustn)
Category: Computers > Programming
Asked by: davidparks21-ga
List Price: $2.00
Posted: 13 Jan 2003 22:02 PST
Expires: 12 Feb 2003 22:02 PST
Question ID: 142397
Hi, I have a Yes or No question which will help me determine if I
should move forward with learning XSLT in depth or whether I should
abandon it.

I am looking for a qualified yes or no answer from someone who knows
XSLT well enough to make this judgement.

I have a simple XML document that looks something like the following,
esentially it is a list of timings that were taken:

<root>
  <headter>
    <item>Date</item>
    <item>TimeValue</item>
  </header>
  <rowdata>
    <item>12/1/2002</item>
    <item>5</item>
  </rowdata>
  <rowdata>
    <item>12/2/2002</item>
    <item>5</item>
  </rowdata>
</root>

This is a very simplified example. It's an extract of a table from a
database and the actual case will have thousands of rows of data (i.e.
thousands of rowdata nodes).

What I am need to do is reformat the data in a form that looks like
this:

week 1 average value: 17
week 2 average value: 8
...

So what needs to be done is to take a set of rowdata nodes based on
the time period (looking for all rowdata values within a given week)
and then average all of those values together.

In XSLT will I be able to do the comparisons of date and do the
mathmatical calculations?

Again I'm just looking for a yes/no answer with a very brief
qualification of the answer, I just need to know if I should continue
looking into this as a possibility or whether I should give up now and
go with code writing to do it.

Thanks!
David

p.s. I will be using the Saxon parser in Java if it makes any difference to you.
Answer  
Subject: Re: Need someone with XSLT knowledge to give relatively simple advice (yes/no Qustn)
Answered By: mathtalk-ga on 14 Jan 2003 16:04 PST
Rated:5 out of 5 stars
 
Date comparisons are a bit of a pain, but they can be done in XSLT
(I've done it).  If you were looking for the method of "least
programming", I'd suggest importing the records into a SQL database
(like MSDE or MySQL) and doing a group by.  Your output labelling
"week 1", "week 1", etc. conceals what really is meant by these
groupings (week starting with Sunday?), but a good SQL query could
handle this with less "verbiage" than XSLT.  Any procedural language
with arrays in which you can loop through the records will be easier
to use than XSLT.  So in terms of quick turnaround:

1) SQL
2) procedural code
3) XSLT

But if you wanted an exercise to cut your teeth on in XSLT, this would
be a nice one.  It's not your first transform to write, but could
easily be the third or fourth.  I'd be glad to give some hints.

regards, mathtalk

Clarification of Answer by mathtalk-ga on 14 Jan 2003 19:48 PST
Thanks, David, for the kind words of encouragement!  You've caught me
away from the XML/XSLT portion of my library, but I'll be happy to
post some recommended reading & "code" samples.

To answer the narrow question, yes, XSLT supports both floating point
and integer arithmetic in expressions, which are essentially those of
the XPATH language.  See this from the friendly folks at W3C:

http://www.w3.org/TR/1999/REC-xpath-19991116.html#section-Expressions

Just for curiosity's sake you might be interested in this page on the
history of XSLT (and the surrounding article, too, for that matter):

http://www.topxml.com/xsl/articles/xslt_what_about/31290105.asp

regards, mathtalk-ga
davidparks21-ga rated this answer:5 out of 5 stars
Thanks. I will continue my education on XSLT then. It seems like a
powerful option to keep us from needing to program transformations of
XML data, however these transformations can be sometimes rather
complex.  If you're able to add a comment after the rating is done can
you let me know if math functions such as +, -, *, / are possible as
well?

Thanks very much!
David

Comments  
Subject: Re: Need someone with XSLT knowledge to give relatively simple advice (yes/no Qustn)
From: mathtalk-ga on 12 Sep 2003 09:03 PDT
 
Hi, David:

I'm not sure if you'll see this, but on your most recent question
(about relocating the user Desktop folder in XP), your expiration of
it prevents any further Comments from being posted there.

As you noted, you found denco-ga's suggestion to be a satisfactory
solution.  For future reference there are two ways to be sure that
this suggestion was being offered by an "answerer" (or Google Answers
Researcher as we are supposed to refer to ourselves).

First, only Google Answers Researchers can post Requests for
Clarification to your questions.  So that's a clear sign that denco-ga
could have received payment for his suggestion, if you'd allowed
him(?) to post it as such.

Second, even when a Researcher posts a Comment, the Researcher's name
will be highlighted and appear underlined (it's in fact a hot link to
a summary of their previous Answers).

Knowing your past generousity, I find it difficult to believe that you
would not wish denco-ga to receive the payment for this question (and
perhaps a good rating as well).  Once a Question is closed, however,
there is no "going back".

What I would be so bold as to suggest, trading on the fact that I've
had some success in answering this old question for you, is that you
might post a new $3 item with "For Denco-ga Only" in the subject
title.  It will cost an extra 50 cents for the new post, but I think
it would buy a great deal of goodwill!

Thanks for your consideration,
mathtalk-ga
Subject: Re: Need someone with XSLT knowledge to give relatively simple advice (yes/no Qu
From: davidparks21-ga on 12 Sep 2003 13:14 PDT
 
Thanks for the clafication mathtalk-ga, I wasn't clear on what
happened. I have emailed google support to try and clear it up,
denco-ga's response was the answer I was looking for so I agree with
you completely.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy