Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xsl totals composed from variables

From: Joe Kesselman <keshlam-nospam@-------.--->
To: NULL
Date: 11/5/2006 11:05:00 PM

the_jos wrote:
> I then found out that xml/xsl does not
> handle variables the way a program language does. But that's not
> entirely strange, given the nature of xsl.

Actually, XSLT handles variables very much the same way other 
nonprocedural programming langauges do -- single-assignment, lexically 
scoped.

> For my question, I just wanted to determine the value of legs (25),
> chair_top (25) and table_top (50) given the price of wood and work.

This is as much a data-representation problem as a stylesheet problem. 
If your data hierarchy matches the structural hierarchy, gathering the 
structured information becomes much easier -- for example, if the data 
is something like

<set>
  	<table quantity="1">
		<top quantity="1" hours="2" wood="2" price="100"/>
		<leg quantity="4" hours="1" wood="1" price="25"/>
	</table>
  	<chair quantity="4">
		<top quantity="1" hours="1" wood="1" price="50"/>
		<leg quantity="4" hours="1" wood="1" price="25"/>
	</chair>
</set>

then this becomes a fairly straightforward recursive 
multiply-and-accumulate problem. (Value at any node is sum of values of 
its children times their quantity, plus its own value if any.) That 
isn't necessarily the best solution; there are several other possible 
ways to structure this.

Note that this provides all the information in a single document. If you 
really wanted to separate the values from the

Picking the minimum of two results is simple once you've got the values, 
of course.


This isn't a typical use of XSLT, of course. It's more typical of what 
one will do using XQuery... but XQuery and XSLT 2.0 are essentially the 
same language with different syntax.


-- 
() ASCII Ribbon Campaign  | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent