Re: [xsl] alternative to namespace exmaple

Subject: Re: [xsl] alternative to namespace exmaple
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 13 Jan 2005 11:09:31 -0500
Dmitri,

I think you are right in suspecting that this is over-engineered -- if that's what you're suspecting.

<us:item xmlns:us="www.uss.com">
<us:value>4000</us:value>
</us:item>

<them:item xmlns:them="www.them.com">
<them:value>1000</them:value>
</them:item>

Could more easily be


<item whose="us">
  <value>4000</value>
</item>
<item whose="them">
  <value>1000</value>
</item>

etc.

Then

<xsl:value-of select="format-number(sum(//us:value) - sum(//them:value),
'###,###,##0.00')" />

and


<xsl:value-of select="format-number(sum(//*[local-name() = 'value']),
'###,###,##0.00')" />

could be


<xsl:value-of select="format-number(sum(//item[@whose='us']/value) - sum(//item[@whose='them']/value),
$sum-format)" />


and

<xsl:value-of select="format-number(sum(//value), $sum-format)" />

(declaring $sum-format as '###,###,##0.00')

Without knowing more about it, I think the application of namespaces doesn't get you much here: it merely makes things messy and complicated. (I can't, however, say what impact this would have on performance, if any, without trying it.)

Things could be simplified even further if you don't actually need those <item> element wrappers (label the values themselves with their "owners").

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread