aspose file tools*
The moose likes XML and Related Technologies and the fly likes Jaxb  recursive nodes    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Jaxb  recursive nodes    " Watch "Jaxb  recursive nodes    " New topic
Author

Jaxb recursive nodes

Ramans mann
Greenhorn

Joined: Aug 08, 2011
Posts: 7
Can any body tell me how to fix this .I am using http://jaxb.java.net/ latest version


<xsd:element name="aaa">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="aaa_structure">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="study" type="exceptionType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="exceptionType">
<xsd:sequence>
<xsd:element name="study" type="exceptionType"/>
</xsd:sequence>
</xsd:complexType>

</xsd:sequence>
<xsd:attribute name="app_id" type="xsd:string" />
</xsd:complexType>
</xsd:element>




I got this error

[java] [ERROR] src-resolve: Cannot resolve the name 'exceptionType' to a(n) 'type definition' component.
[java] line 22 of file:/Jaxb/src/MySchema.xsd

[java] [ERROR] s4s-elt-must-match.1: The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)*). A problem was found starting at: complexType.
[java] line 26 of file:/Jaxb/src/MySchema.xsd
Ramans mann
Greenhorn

Joined: Aug 08, 2011
Posts: 7
I think it is a problem with JAXB Reference APi i am using (http://jaxb.java.net/ latest version )

It does not seems to be supporting "name" attribute

<xsd:complexType name="exceptionType">
Ramans mann
Greenhorn

Joined: Aug 08, 2011
Posts: 7
Java mann wrote:I think it is a problem with JAXB Reference APi i am using (http://jaxb.java.net/ latest version )

It does not seems to be supporting "name" attribute

<xsd:complexType name="exceptionType">


I am not sure if this is the rigth approuch
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 535
    
    3
>I think it is a problem with JAXB Reference APi i am using (http://jaxb.java.net/ latest version )
Not really.

>It does not seems to be supporting "name" attribute
That's an illusion. You've not read the error message properly and that you've an invalid schema per w3c schema recommendation.

>[java] [ERROR] src-resolve: Cannot resolve the name 'exceptionType' to a(n) 'type definition' component.
[java] line 22 of file:/Jaxb/src/MySchema.xsd

That means the type "exceptionType" cannot be found as a top level element of xsd:complexType with name="exceptionType". This is how to fix your schema fragment.

Move the block:

and reposition it outside of the block <xsd:element name="aaa">...</xsd:element> and as a child element directly under xsd:schema element.

>[java] [ERROR] s4s-elt-must-match.1: The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)*). A problem was found starting at: complexType.
[java] line 26 of file:/Jaxb/src/MySchema.xsd

This is another aspect of the same error of positioning the block xsd:complexType directly under xsd:sequence element. It literally means xs:complexType cannot be an immediate child element of xsd:sequence.

In fact, jaxb does a good job on pulling out these two error messages.

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 535
    
    3
Furthermore, I forgot to mention, when you do any kind of recursive algorithm or templating or type declaration, you should implement an exit provision one way or another. The same here.

<xsd:element name="study" type="exceptionType"/>


It is on the complexType and you need at least one occurrence of the element study as parent. If it is further on the outer element declaration as well, the parent study may not occur at all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jaxb recursive nodes