xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikhil Dinesh <nikh...@seas.upenn.edu>
Subject Re: Elements from imported namespaces
Date Fri, 09 Jul 2004 13:46:47 GMT
Im not using an explicit XmlAnyType. The type is FooElement. Im just
reading it in messaging the XmlSaxHandler. And as per the W3 recommendation
it is not the case that it has to be the last element. For example, I could
include attributes from another namespace which are not in any ModelGroup.
But there is some interaction between the targetNamespace and the imported
namespace which if I understand correctly is:

<element name="Foo" type="foo:FooElementType" > (the name Foo will now be
in the targetNamespace. I think the children preserve the old namsepace)

<element ref="foo:FooElement" > (the namespace is preserved)

The default value for processContents is 'strict' so they should be typed.

Finally, the schema below does not allow elements of AnyType. Thus seeing
such an element should cause errors. Right? And the validator should know
that it is of BarType because the container element will be of type
BarElementDocument thats how the instance of XmlSaxHandler is created.

-Nikhil


On Fri, 9 Jul 2004, Noah Campbell wrote:

> If memory serves, if you use an XmlAnyType you need to place it last
> in your sequence since the schema validator (and xmlbeans) won't know
> if BarType is part of BarType or FooElementDocument.
>
> Noah
>
> On Thu, 8 Jul 2004 21:53:57 -0400 (EDT), Nikhil Dinesh
> <nikhild@seas.upenn.edu> wrote:
> > Hi,
> >
> > Im referencing a global element from an imported namespace in my schema.
> > But when I read an instance in, the referenced element takes the type
> > XmlAnyType instead of the correct one. The schema looks like:
> >
> > <schema xmlns:target="http://bar.com"
> >         xmlns:foo="http://foo.com"
> >         targetNamespace="http://bar.com"
> >         elementFormDefault="qualified">
> >
> >   <import namespace="http://foo.com" schemaLocation="..." />
> >
> >   <complexType name="BarType" >
> >     <sequence>
> >       <element ref="foo:FooElement" minOccurs="1" maxOccurs="1" />
> >       <element name="Bar" type="target:BarType" minOccurs="0" maxOccurs="unbounded"
/>
> >     </sequence>
> >   </complexType>
> >
> > </schema>
> >
> > Reading in a FooElementDocument works fine with the elements taking their
> > appropriate types. But reading a BarType document results in the
> > FooElements having XmlAnyType.
> >
> > Ive tried putting the FooElement in both namespaces and setting an
> > ErrorListener with the validateOnSet option. But no errors are flagged and
> > behaviour is the same whichever I choose. Im reading the document in by
> > messaging the SAXHandler.
> >
> > Any suggestions as to what I might be doing wrong?
> > Thanks,
> > Nikhil
> >
> > - ---------------------------------------------------------------------
> > To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> > Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
> >
> >
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message