File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XSD Variable Attributes of Complex type, Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "XSD Variable Attributes of Complex type," Watch "XSD Variable Attributes of Complex type," New topic
Author

XSD Variable Attributes of Complex type,

Hendrik Louw
Greenhorn

Joined: Mar 01, 2007
Posts: 5
Hi All.
We are defining an XSD to expose to the outside world. Part of the XSD defines which product you have selected. Now my problem is that altho all our products have a set of standard attributes which are shared, they each also have a set of specific attributes. Now depending on what "type" of product you select. I would like to use the XSD to validate that all the required attributes are on the XML for that paticular product.

I've currently been able to do this via the following.



This works, but unfortunatly it requires that you create an element of <ProductB> to add Speakers to the order, and <ProductA> element to add Headphones. (where each requires an additional attribute each)

What I would like is to have a single <Product> element, with an attribute defining the type. Then according to the type validate that all the required attributes have been entered.

So that

would not validate, but

Does.

So far I haven't been able to find any way to do this. Any ideas ?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2300
Sorry I could not understand the question fully.

If you are saying that just for adding one attribute you have to make one more complexType then I would suggest you to extend the first complexType and add the new attribute to make a new complexType.


Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: XSD Variable Attributes of Complex type,
 
Similar Threads
XML schema validation
MS Exchange web service: If the 'nillable' attribute is false in the schema, the 'xsi:nil' attribute
schema generation
XSD : Extending "Element"
Unique particle attribution rule bit me - why?