What is the benefit of using attribute groups over attributes in defining an XSD Schema?
Ok… so I can declare them elsewhere and reference them…
What else?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically, as cbp says, you can re-use them. It’s also easier to make modifications to the attributes of multiple elements this way.
In general, I myself sometimes use them when I have several elements that are reasonable similar, except for the name and a few other attributes. Thus, those elements all share one or more attribute groups and sometimes have additional attributes.
Example: you’re exporting a database with 40 tables. All tables have an ID as identifier and a few have a start/end date. There are also attributes for the other fields. So you can create one attribute group for the ID, adding restrictions to that group as need be. A second attribute group would be created for the dates including their restrictions. Maybe the database structure even allows some more groupings.
An alternative method would be by creating new complex types, but if you want to add child elements to your element then you need to add those to the complex type too. And you might not want to have all your elements use the same complex type, thus attribute groups are useful where you can’t use complex types to add similar groups of attributes.