[erlang-questions] Re: xmerl namespace handling

Robert Raschke rtrlists@REDACTED
Mon Aug 3 13:41:31 CEST 2009


On Mon, Aug 3, 2009 at 12:11 PM, Dave Pawson <dave.pawson@REDACTED> wrote:

> 2009/8/3 Robert Raschke <rtrlists@REDACTED>:
> > Hmm replying to myself, sorry 'bout that.
>
> > I figured out that namespaces are kept as atoms in the xmlNamespace
> record
> > and the 'default' field of that record has a default value of []. So if I
> > change the first clause of mk_Ell_namespace/3 to read like follows, I can
> > get my XML validated:
>
> Differentiate between default namespace and null namespace?
> http://www.w3.org/TR/xml-names/#defaulting
>
> An element without a namespace inherits from it's nearest ancestor
> specifying a namespace
>
> http://www.w3.org/TR/REC-xml-names/#scoping
>
>
> HTH
>
>
>
Yeah, my case is the following:

I have XML:

<n:a xmlns:n="foo">
    <n:b>
        <c xmlns="bar">
           ...
        </c>
    </n:b>
</n:a>

And I have an XSD with a targetNamespace of "bar" for the tree rooted in <c>

I want to check the tree starting with element <c> against my XSD. In the
current xmerl I can't do that, since it appears to check the parents
namespaces before the default on the node. So, after selecting the <c>
element, I get an error like

{element_not_in_schema,
    [c,
     {c,[],foo}, ...

Thus <c> has received the namespace of its parent by the processing in
xmerl_xsd, instead of its own default namespace!

Robby


More information about the erlang-questions mailing list