Martin,
Thank you for taking the time to type up that code for me. It really helped
me to make my design decision. I am working on a proof-of-concept for a
calculation and report engine.
My project is to create a calculation engine that allows users to select
multiple calculations that they want performed, input the required date, and
receive a report that contains their results. Based selected calculations, a
dynamically-generated form is presented with the parameters needed for the
calculations. I will use a dynamically-created XSD to generate the parameter
entry form and validate the data.
I wanted a design that would allow me to revise and add available
calculations without redeploying compiled code. I was thinking that I could
do the calculations using XSDs, since most of the calculations are simple
arithmetic and iteration. By doing the calculations in XSLT rather than
compiled code, I could update or add XSLTs and database entries without
changing the compiled code.
I have come to the conclusion that XSLT is not a good choice for simple
calculations, even relatively simple ones, because it lacks some of the
functionality that I need and would require a lot more developer effort. I
have changed my design to use C# to do the calculations, output them as XML,
and use XSLT to transform the results to formatted HTML. I may revise the
engine later, abstractring and extracting out calculation descriptions as
XML files that C# code reads to determine how to perform calculations on the
data, depending on if I can avoid writing much of a math parser. I certainly
want to avoid redesigning even a small subset of content-based MathML. My
current OOP design contains the majority of the functionality in the base
class and the specific calculations in derived classes, so I will have to
deploy small DLLs, but that will work okay.
Would you say that XSLT is most effectively used for transforming data,
rather than general calculation? The most common uses that I have seen are
XHTML output and XML-to-XML data format changes.
Thanks again for your help. You helped me avoid taking a path that would
have been unproductive.
Regards,
David S. Alexander
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
David S. Alexander wrote:
I still cannot get my calculation to work correctly. My actual XML is,
<?xml version="1.0" encoding="utf-8" ?>
<Parameters xmlns="http://www.tempuri.org/Parameters">
Namespaces are quite important, in your earlier post you also posted your
"actual" XML but that did not show any namespaces.
With that default namespace declaration all elements in the example are in
that namespace and XSLT templates need to cater for that so you need e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://www.tempuri.org/Parameters"
version="1.0">
<xsl:template match="ns1:*">
<xsl:element
name="{local-name()}"
namespace="http://www.tempuri.org/CalculatorParameters">
<xsl:apply-templates select="@* | node() "/>
</xsl:element>
</xsl:template>
<xsl:template match="ns1:DateOfBirth">
<xsl:element name="{local-name()}"
namespace="http://www.tempuri.org/CalculatorParameters">
<xsl:attribute name="Age">
<xsl:value-of
select="../following-sibling::ns1:AnalysisDate/@Year - @Year" />
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/