Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Schema default value not honored for complex type
Schema default value not honored for complex type [message #906527] Sat, 01 September 2012 19:32 Go to next message
Derek Wallace is currently offline Derek Wallace
Messages: 5
Registered: March 2012
Junior Member
Hi,
I have a simple schema.
I have some elements with simple type and an element as a complex type. The complex type consists of a number of simple type elements.

All elements have a default value.

When i use the Outline view in Eclipse to add elements, the default value is honored for simple types but not for the elements in the complex type.

Ive attached the .xml file and the .xsd.

If i use File - New - Other - XML and follow the wizard to create the initial .xml based on the schema, it adds the elements (simple and complex) and the default of the simple and complex types are honored.

here is how thie file first looks.
<?xml version="1.0" encoding="UTF-8"?>
<del:bookstore xmlns:del="xxxxdel" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxxdel example2.del.xsd ">
<del:Simple>789</del:Simple>
<del:SimpleList>DSSEA</del:SimpleList>
<del:Complex>
<del:Age>39</del:Age>
<del:Color>White</del:Color>
</del:Complex>
</del:bookstore>


If i now manually add a 2nd instance of the Simple type (via the Outline window, righ click, add after, Simple) it is correct.
<?xml version="1.0" encoding="UTF-8"?>
<del:bookstore xmlns:del="xxxxdel" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxdel example2.del.xsd ">
<del:Simple>789</del:Simple>
<del:Simple>789</del:Simple>
<del:SimpleList>DSSEA</del:SimpleList>
<del:Complex>
<del:Age>39</del:Age>
<del:Color>White</del:Color>
</del:Complex>
</del:bookstore>


If i now manually add a 2nd instance of the Complex type (via the Outline window) it is NOT correct.


<?xml version="1.0" encoding="UTF-8"?>
<del:bookstore xmlns:del="xxxx/del" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxxdel example2.del.xsd ">
<del:Simple>789</del:Simple>
<del:Simple>789</del:Simple>
<del:SimpleList>DSSEA</del:SimpleList>
<del:Complex>
<del:Age>39</del:Age>
<del:Color>White</del:Color>
</del:Complex>
<del:Complex>
<del:Age>del:Age</del:Age>
<del:Color>del:Color</del:Color>
</del:Complex>
</del:bookstore>


Im using Eclipse Helios.
Version: 3.7.1
Build id: M20110909-1335

Thx
Derek
Re: Schema default value not honored for complex type [message #906559 is a reply to message #906527] Sat, 01 September 2012 21:31 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Derek,

Please use the Web Tools forum to ask questions about the Eclipse
XML/XSD tools. This form is for asking questions about the XSD API.


On 01/09/2012 9:32 PM, Derek Wallace wrote:
> Hi,
> I have a simple schema.
> I have some elements with simple type and an element as a complex type. The complex type consists of a number of simple type elements.
>
> All elements have a default value.
>
> When i use the Outline view in Eclipse to add elements, the default value is honored for simple types but not for the elements in the complex type.
>
> Ive attached the .xml file and the .xsd.
>
> If i use File - New - Other - XML and follow the wizard to create the initial .xml based on the schema, it adds the elements (simple and complex) and the default of the simple and complex types are honored.
>
> here is how thie file first looks.
> <?xml version="1.0" encoding="UTF-8"?>
> <del:bookstore xmlns:del="xxxxdel" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxxdel example2.del.xsd ">
> <del:Simple>789</del:Simple>
> <del:SimpleList>DSSEA</del:SimpleList>
> <del:Complex>
> <del:Age>39</del:Age>
> <del:Color>White</del:Color>
> </del:Complex>
> </del:bookstore>
>
>
> If i now manually add a 2nd instance of the Simple type (via the Outline window, righ click, add after, Simple) it is correct.
> <?xml version="1.0" encoding="UTF-8"?>
> <del:bookstore xmlns:del="xxxxdel" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxdel example2.del.xsd ">
> <del:Simple>789</del:Simple>
> <del:Simple>789</del:Simple>
> <del:SimpleList>DSSEA</del:SimpleList>
> <del:Complex>
> <del:Age>39</del:Age>
> <del:Color>White</del:Color>
> </del:Complex>
> </del:bookstore>
>
>
> If i now manually add a 2nd instance of the Complex type (via the Outline window) it is NOT correct.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <del:bookstore xmlns:del="xxxx/del" xmlns:xsi="xxxxXMLSchema-instance" xsi:schemaLocation="xxxxxdel example2.del.xsd ">
> <del:Simple>789</del:Simple>
> <del:Simple>789</del:Simple>
> <del:SimpleList>DSSEA</del:SimpleList>
> <del:Complex>
> <del:Age>39</del:Age>
> <del:Color>White</del:Color>
> </del:Complex>
> <del:Complex>
> <del:Age>del:Age</del:Age>
> <del:Color>del:Color</del:Color>
> </del:Complex>
> </del:bookstore>
>
>
> Im using Eclipse Helios.
> Version: 3.7.1
> Build id: M20110909-1335
>
> Thx
> Derek
>
Previous Topic:one XML element value as other xml element value
Next Topic:Declare a default attribute
Goto Forum:
  


Current Time: Sat Oct 25 14:37:38 GMT 2014

Powered by FUDForum. Page generated in 0.02428 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software