views:

456

answers:

1

I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the beautiful XML we would like to produce.

One of the things we do is transform nodes inline and importing nodes from one XML document to another.

Sadly , when you save nodes to an XmlTextWriter (actually whatever XmlWriter.Create(Stream) returns), the namespace definitions get all thrown in there, regardless of it is necessary (previously defined) or not. You get kind of the following xml:

<root xmlns:abx="http://bladibla"&gt;
<abx:child id="A">
<grandchild id="B"> <abx:grandgrandchild xmlns:abx="http://bladibla" />
</grandchild>
</abx:child>
</root>

Does anyone have a suggestion as to how to convince .NET to be efficient about its namespace definitions?

Thanks, Boaz

PS. As an added bonus I would like to override the default namespace, changing it as I write a node.

+1  A: 

This post might be helpful. Also take a look at Namespaces property of XmlTextWriter\XmlTextReader classes.

aku