xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Radu Preotiuc-Pietro" <ra...@bea.com>
Subject RE: Elements from imported namespaces
Date Mon, 12 Jul 2004 16:58:29 GMT
I see, then the only other thing I can think of is making sure that you use BarElementDocument
and not BarType. The reason is that your document's type is BarElementDocument; BarType is
the type of the root element, the document contains the root plus other things, like the XML
decl.
I definitely do not believe that import is at fault here, I have used it without any problems
(btw, are you compiling the two Schema files at the same time?)

Radu

-----Original Message-----
From: Nikhil Dinesh [mailto:nikhild@seas.upenn.edu]
Sent: Saturday, July 10, 2004 9:01 AM
To: xmlbeans-user@xml.apache.org
Subject: RE: Elements from imported namespaces


Yes I had a "BarElement" declaration. The SAX event generator code is the
same as the one I use to generate "FooElementDocument" except that an
additional event generating "BarElement" is wrapped around the one one
generating "FooElement". ie.

For "FooElementDocument" the events look like:

startElement- foo:FooElement xmlns:foo="http://foo.com"

.....

endElement- foo:FooElement

For "BarElementDocument" the events look like:

startElement- target:BarElement xmlns:target="http://bar.com"

 startElement- foo:FooElement xmlns:foo="http://foo.com" (I also tried
    putting this namespace declaration on BarElement but that doesnt work
    either)
  ....

 endElement- foo:FooElement

endElement- target:BarElement

As Id mentioned, when I read in FooElementDocument, everything comes out
fine.

Thanks,
Nikhil


On Fri, 9 Jul 2004, Radu Preotiuc-Pietro wrote:

> Let me see if I can help,
> Coming back to your original Schema, what is the root element in your XML tree? Your
Schema appears to declare no global element, just a global type.
> If you had an <element name="BarElement" type="target:BarType"/> in there and a
document whose root is "bar:BarElement", then it would work (I tried it, but with normal parse).
> Or, alternatively, there may be a problem in the code that builds the document via SAX
events, which you haven't posted.
>
> Radu
>
> -----Original Message-----
> From: Nikhil Dinesh [mailto:nikhild@seas.upenn.edu]
> Sent: Friday, July 09, 2004 6:47 AM
> To: xmlbeans-user@xml.apache.org
> Subject: Re: Elements from imported namespaces
>
>
> 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/
>
>
> - ---------------------------------------------------------------------
> 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