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 Putting Common attribute groups in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Putting Common attribute groups in "headers"" Watch "Putting Common attribute groups in "headers"" New topic
Author

Putting Common attribute groups in "headers"

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
Say I have a Camera xsd and a model xsd which both make use of an attribute group called Vector
How do I make up the xsd file structure? and how do I share the attribute groups in the xsd files?
thanks
Jack
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 512
    
    3
You've got to be much more precise rather than making some partial abstraction of the statement of the problem because it's got to have some fairly intriguing co-relation among the elements and attributes to come up with a correct structure or structures. In particular, you should mention clearly in what namespaces are Camera, model and Vector and the attributes contained in the attribute group Vector.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
g tsuji wrote:You've got to be much more precise rather than making some partial abstraction of the statement of the problem because it's got to have some fairly intriguing co-relation among the elements and attributes to come up with a correct structure or structures. In particular, you should mention clearly in what namespaces are Camera, model and Vector and the attributes contained in the attribute group Vector.


Attribute Group - Vector -> x, y, z

In Camera.xsd
Camera -> Eye Pos -> Vector -> x,y,z

In Model.xsd
Model -> Frame -> Mesh -> Vertex -> Vector -> x, y,z


Inside Camera and Model.xsd, both of which make use of the attribute group Vector, however, I don't want to define them twice in both xsds..
I want to put the attribute group vector in a common file which looks like the .h header in C++ so that they can share it and I don't have to re-define them in each file
Please let me know if you need further info.
BTW, belated merry christmas. happy holidays
Thanks
Jack
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 512
    
    3
Very well, as you've mentioned nothing about the possible complication on namespaces and that Camera and Model (or model?) schemas are completely independent, then I would not be surprised a simple xs:include would do. Just add this line right after the xs:schema root element of the schemas Camera.xsd and model.xsd.

and in the Common.xsd (supposedly in the same directory of Camera.xsd or Model.xsd), isolate out the definition of the attribute group.

And then you use ref="Vector" to refer to the attribute group Vector in the elements EyePos (no space admissible) and Vertex or their types.

Just be careful that if Camera.xsd and Model.xsd involve anything with non-null targetNamespace, xs:include could become problematic and you might have to test around with xs:import. In any case, since nothing of the sort is mentioned at all, I would leave the answer as such hoping no complications come up.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
I would say Camera and Model are completely independent, do you mean that a model would not use an instance of Camera? Sorry, I am a newbie to xsd
Thanks
Jack
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 512
    
    3
I would say Camera and Model are completely independent,...

That's fine.
...do you mean that a model would not use an instance of Camera?

You can, but the Common would have to be the same copy (meaning one single copy in the same directory...) if there is no other complication to determine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Putting Common attribute groups in "headers"