Hi Aki
On 05/03/12 17:07, Aki Yoshida wrote:
Hi Sergey, Dan,
We are currently not enforcing the namespace bindings to preserve the
namespace prefix values. For most applications, there is no need to
preserve the prefix values. But I just noticed that if you have an
element value typed as QName, you want to preserve its original
prefix value so that this QName value can be interpreted correctly by
the schema-aware binding framework.
For example, if you have an input XML:
<a:foo xmlns:a="urn:abc">
<a2:bar xmlns:a2="urn:abc">a2:text</a2:bar>
</a:foo>
and suppose the content of element bar is of type QName.
If we are transforming from {urn:abc}* to {urn:a}*, we should not
simply generate:
<a:foo xmlns:a="urn:a">
<a:bar>a2:text</a:bar>
</a:foo>
Instead, we should generate:
<a:foo xmlns:a="urn:a">
<a2:bar xmlns:a2="urn:a">a2:text</a2:bar>
</a:foo>
so that the QName a2:text can be correctly interpreted.
Currently, the output transformer preserves all the non-empty
namespace bindings, so it generates the desired output in the above
case. But it does not preserve the default namespace binding, so the
desired output is not generated, if the input is given as:
<a:foo xmlns:a="urn:abc">
<bar xmlns="urn:abc">text</bar>
</a:foo>
In this case, we are generating:
<a:foo xmlns:a="urn:a">
<a:bar>text</bar>
</a:foo>
instead of generating the desired output
<a:foo xmlns:a="urn:a">
<bar xmlns="urn:a">text</bar>
</a:foo>
I think we need an option to preserve the namespace prefixes including
the empty ones. But currently, there is an explicit logic to replace
all empty prefixes with non-empty ones and to generate an empty prefix
only if it is explicitly configured to use the default namespace for
that particular namespace.
In order to remain compatible with this latter usage, we can activate
this prefix preserving mode only if this defaultNamespace setting is
inactive.
For the inbound, the prefixes are not preserved at all.
Do you think we should add this prefix preserving mode as an explicit
option or as the default behavior?
I think having the prefix preserving mode makes sense, I'm not exactly
sure if it should be set by default :-), probably yes... It seems that
the default namespace mode should always take precedence for a given
namespace, if it's set
Thanks, Sergey
regards, aki