João,
I think we're nearly there. Your input XML has no namespaces to deal with;
you just need all elements in the output to be in the
"required-excel-stylesheet" namespace, correct? If this is the case, you
don't need to change or set an xpath default namespace in your stylesheet.
You just need to make sure any elements you throw to the output are in the
appropriate namespace. For example, this modified version of your XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:variable name="taxes" as="item()*">
<xsl:for-each select="//value">
<xsl:element name="tax">
<xsl:element name="value">
<xsl:value-of
select="format-number(.,'#.00')"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:element name="DocumentExcelElement"
namespace="required-excel-stylesheet">
<xsl:element name="SomeExcelElement"
namespace="required-excel-stylesheet">Hello World</xsl:element>
<xsl:element
name="SomeOtherExcelElement" namespace="required-excel-stylesheet">
<xsl:value-of
select="format-number(sum($taxes//value),'#.00')"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
transforms this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<values>
<value>0.123</value>
<value>0.234</value>
</values>
into this:
<?xml version="1.0" encoding="UTF-8"?>
<DocumentExcelElement xmlns="required-excel-stylesheet">
<SomeExcelElement>Hello World</SomeExcelElement>
<SomeOtherExcelElement>0.35</SomeOtherExcelElement>
</DocumentExcelElement>
Is that what you are looking for? Note also that I changed
sum($taxes/value) to sum($taxes//value)...otherwise I always got 0.00...
Cheers,
...sam
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--