[Mono-devel-list] Re: not-so-good patch

Andrew Skiba andrews at mainsoft.com
Thu Feb 10 05:02:43 EST 2005

Hello, Atsushi.

My patch is not so good, because it fixes what is easier to fix, instead
of fixing the bad design. Let me explain how I think namespaces should
be processed in XSLT. All processing should be done only on the output
tree. It's irrelevant when an element is evaluated, what matters is what
they write to the output. For example xsl:if sometimes will not write
anything. Today when user declares a namespace, it's processed by the
first construction that comes after it. In the following example it's

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:n1="n1">

<xsl:variable name="v">

<xsl:template match="/" xmlns:n2="n2">
	<aaa xmlns:n3="n3">
		<bbb xmlns:n4="n4" xmlns:n1="n1"/>
	<xsl:copy-of select="$v"/>


<aaa xmlns:n3="n3">
   <bbb xmlns:n4="n4" xmlns:n1="n1" />
<ccc xmlns:n1="n1" />

instead of

<aaa xmlns:ns1="ns1" xmlns:n2="n2" xmlns:n3="n3">
	<bbb xmlns:ns4="ns4" />
<ccc xmlns:ns1="ns1" />

If you add here included and imported stylesheets with other namespaces
declared in them, the situation will be much worse.

But namespace processing should look simple.

1. On the compilation stage every compiled element gets the full list of
all namespaces, declared in it and its parents.
2. When an element is written to the output, it gets the list of the
compiled element that writes it.
3. From the list of namespaces you hide standard ones and those that
were already written for the parents in the output tree. The rest you
write out.

Nothing complicated. I don't mention here namespaces that come from
attributes and the input XML, as their processing does not change my idea.

Andrew Skiba.

More information about the Mono-devel-list mailing list