Hi Tamas,
As far as your ordering issue, you may want to check out the following sample:
http://xmlbeans.apache.org/samples/OrderMatters.html
The parse issue you are seeing looks like a standard validation kind
of issue. In other words, I think XMLBeans is expecting the Node you
are parsing to look differently than it does. What is the difference
in content when you do a
for(...)
System.out.println(container.getComponentdefArray() [idx].xmlText())
vs.
System.out.println(node);
HTH,
-jacobd
On Tue, May 6, 2008 at 6:29 AM, Barta Tamás <[EMAIL PROTECTED]> wrote:
> Hi All!
>
> A have a simple XML format:
>
> <page>
> <container>
> <componentdef type="type1">
> <property name="path" value="/WEB-INF/components/hello.jsp"/>
> </componentdef>
> <componentref id="ref1"/>
> </container>
> </page>
>
> The "container" element contains zero or more "componentdef" and
> "componentref" elements in
> any order. Part of XSD:
>
> ...
> <xs:complexType name="container">
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element name="componentdef" type="bl:componentdef"/>
> <xs:element name="componentref" type="bl:componentref"/>
> </xs:choice>
> ...
> </xs:complexType>
> ...
>
>
> The "Container" class (generated by xmlbeans) contains a
> getComponentdefArray() and a
> getComponentrefArray() methods. But I need the real order of these
> elements. So I decided
> to use DOM API:
>
>
> NodeList nodes = container.getDomNode().getChildNodes();
> for (int i=0; i<nodes.getLength(); i++) {
> Node node = nodes.item(i);
> String name = node.getNodeName();
>
> System.out.println(node);
> if (name.equals("componentdef")) {
> Componentdef componentdef =
> Componentdef.Factory.parse(node);
> ...
> } else if (name.equals("componentref")) {
> Componentref componentref =
> Componentref.Factory.parse(node);
> ...
> }
> }
>
> But during parsing, the following errors occur:
>
> >> error: cvc-complex-type.4: Expected attribute: type
> >> error: cvc-complex-type.2.4a: Expected element
> '[EMAIL PROTECTED]://xyz.com/a' instead of '[EMAIL PROTECTED]://xyz.com/a'
> here
>
> The system out contains:
>
> <componentdef type="type1" xmlns="http://xyz.com/a">
> <property name="path" value="/WEB-INF/components/hello.jsp"/>
> </componentdef>,
>
>
> How can I use the "parse" method to receive a valid object instance? Why
> doesn't it find the "type" attribute when the node object has it?
>
>
> Thanks, Tamas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
I'm competing in a Half-Ironman distance triathlon to raise money for
the fight against cancer!
Please help support my efforts by going to:
http://www.active.com/donate/tntwaak/jacobd
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]