You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jerry Lawson <je...@virtualsummit.com> on 2000/10/27 23:40:06 UTC
complexType children question
If I have something like this in my schema:
<element name="Addresses"
<complexType content="elementOnly">
<element name="address" type="string" minOccurs="1"/>
</complexType>
</element>
and my instance doc has:
<Addresses>
<address>123 main st</address>
</Addresses>
xerces 1.2.1 XMLValidator generates and exception:
``Element type "address" must be declared.''
With debugs enabled, I've tracked it down to TraverseSchema
doesn't know the uriIndex of element "address" in the
schema, **unless** I add
elementFormDefault="qualified"
to the <schema declaration.
My question is: what is the proper way to define the namespace
of the subelement in this case, without using the
elementFormDefault attribute ?
thanks for any help -<:O
--
___________________________________________________
Jerry Lawson Virtual Summit, Inc.
Virtual Programmer jerry.lawson@virtualsummit.com
Re: complexType children question
Posted by Jerry Lawson <je...@virtualsummit.com>.
Eric,
I pretty much understand. If I don't use elementFormDefault
(at schema decl) or form (at element decl), I have to change
my xmlns="uri" to xmlns:tgt="uri" in the instance document.
In addition, I have to use the prefix to qualify those elements,
including the root element.
Adding the prefix seems to be more work than simply using
elementFormDefault, so I would think elementFormDefault is
the ``typical'' way to go for this type of problem.
thanks for the xml lesson.
Eric Ye wrote:
>
> I can tell your schema has a targetNamespace defined, and in your xml file,
> you have a ns binding like xmlns = "your target ns uri".
>
> To answer your question, NO, you don't have to use elementFormDefault =
> "qualified" to make it work right, but you can't use the default namespace
> prefix in this case e.g., if you change your example like the following, it
> will work:
>
> <.... xmlns:tgt = "your target ns uri" ...>
> <tgt:Addresses>
> <address> 123 main st </address>
> </tgt:Address>
>
> See the point? if you use the default ns prefix xmlns="your target ns uri"
> in your instance xml file, every element's unprefixed name, e.g. both
> "Addresses" and "address", within the scope of this binding will be
> expanded as a qualified name, i.e. ["your targe ns uri", "Addresses"] and
> ["your targe ns uri", "address"]. However, in your schema, you declared
> <address> element as a locally scope element with an UNQUALIFIED name
> because you don't have elementFormDefault = "qualified" for the whole
> schema, or form="qualified" for this element decl, a unqualified name is
> simply a name with no namespace, when expanded, it will be [null,
> "address"], that is why the validator can't match them properly.
>
> _____
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: "Jerry Lawson" <je...@virtualsummit.com>
> To: <xe...@xml.apache.org>
> Sent: Friday, October 27, 2000 2:40 PM
> Subject: complexType children question
>
> > If I have something like this in my schema:
> >
> > <element name="Addresses"
> > <complexType content="elementOnly">
> > <element name="address" type="string" minOccurs="1"/>
> > </complexType>
> > </element>
> >
> > and my instance doc has:
> >
> > <Addresses>
> > <address>123 main st</address>
> > </Addresses>
> >
> > xerces 1.2.1 XMLValidator generates and exception:
> > ``Element type "address" must be declared.''
> >
> > With debugs enabled, I've tracked it down to TraverseSchema
> > doesn't know the uriIndex of element "address" in the
> > schema, **unless** I add
> > elementFormDefault="qualified"
> > to the <schema declaration.
> >
> > My question is: what is the proper way to define the namespace
> > of the subelement in this case, without using the
> > elementFormDefault attribute ?
> >
> > thanks for any help -<:O
> > --
> > ___________________________________________________
> > Jerry Lawson Virtual Summit, Inc.
> > Virtual Programmer jerry.lawson@virtualsummit.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
--
___________________________________________________
Jerry Lawson Virtual Summit, Inc.
Virtual Programmer jerry.lawson@virtualsummit.com
Re: complexType children question
Posted by Eric Ye <er...@locus.apache.org>.
I can tell your schema has a targetNamespace defined, and in your xml file,
you have a ns binding like xmlns = "your target ns uri".
To answer your question, NO, you don't have to use elementFormDefault =
"qualified" to make it work right, but you can't use the default namespace
prefix in this case e.g., if you change your example like the following, it
will work:
<.... xmlns:tgt = "your target ns uri" ...>
<tgt:Addresses>
<address> 123 main st </address>
</tgt:Address>
See the point? if you use the default ns prefix xmlns="your target ns uri"
in your instance xml file, every element's unprefixed name, e.g. both
"Addresses" and "address", within the scope of this binding will be
expanded as a qualified name, i.e. ["your targe ns uri", "Addresses"] and
["your targe ns uri", "address"]. However, in your schema, you declared
<address> element as a locally scope element with an UNQUALIFIED name
because you don't have elementFormDefault = "qualified" for the whole
schema, or form="qualified" for this element decl, a unqualified name is
simply a name with no namespace, when expanded, it will be [null,
"address"], that is why the validator can't match them properly.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Jerry Lawson" <je...@virtualsummit.com>
To: <xe...@xml.apache.org>
Sent: Friday, October 27, 2000 2:40 PM
Subject: complexType children question
> If I have something like this in my schema:
>
> <element name="Addresses"
> <complexType content="elementOnly">
> <element name="address" type="string" minOccurs="1"/>
> </complexType>
> </element>
>
> and my instance doc has:
>
> <Addresses>
> <address>123 main st</address>
> </Addresses>
>
> xerces 1.2.1 XMLValidator generates and exception:
> ``Element type "address" must be declared.''
>
> With debugs enabled, I've tracked it down to TraverseSchema
> doesn't know the uriIndex of element "address" in the
> schema, **unless** I add
> elementFormDefault="qualified"
> to the <schema declaration.
>
> My question is: what is the proper way to define the namespace
> of the subelement in this case, without using the
> elementFormDefault attribute ?
>
> thanks for any help -<:O
> --
> ___________________________________________________
> Jerry Lawson Virtual Summit, Inc.
> Virtual Programmer jerry.lawson@virtualsummit.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>