This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Need to create nested element with name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Need to create nested element with name" Watch "Need to create nested element with name" New topic
Author

Need to create nested element with name

Dan Grindstaff
Ranch Hand

Joined: Sep 24, 2006
Posts: 138
Hello, I am trying to create an xml doc with elements arranged as follows: XML Doc example Notice that the Field elements are nested in Fields and have a name attribute, the product elements I am fine with so I will not address those. I am building an xsd to accomplish getting the Fields right and having some difficulty. This is a piece of the xsd I have that addresses the fields:


...
and to nest within the datafeed:



So far I am able to build the classes from xjc and marshall the xml but I cannot get the Field element to show up nested in the Fields element. I only get one or the other showing up depending on the element in the FeedType section.

Any help is greatly appreciated!
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
[1] Reason: typo.
<xs:element name="Field" type="Fields" minOccurs="0" maxOccurs="unbounded"/>

It should read:
<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded"/>

[2] The type Field proper : if you allow text content to Field element (as the original erroneous part seems to suggest, xs:string) even if they don't have in the sample, you can do this.
Dan Grindstaff
Ranch Hand

Joined: Sep 24, 2006
Posts: 138
Thank you!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need to create nested element with name
 
Similar Threads
converting xsd to html
jaxb:properties
XML valiadation using schema
servlets and xml
namespace