I believe the three below are syntactically correct; but which are permitted according to conventions (especially in the enterprise)?
The first one below is used in most examples I've seen (e.g. JAXB), but it's verbose:
<xs:annotation>
<xs:appinfo>
<myinfo>don't panic</myinfo>
</xs:appinfo>
</xs:annotation>
This second one below is allowed because any attributes are permitted on <appinfo> (that aren't in xml schema's own namespace). It's shorter, and seems reasonable - but is it conventional?
<xs:annotation>
<xs:appinfo myinfo="don't panic"/>
</xs:annotation>
This last one below is my favourite, because it's so short and doesn't clutter up the schema. I'm sure it's legal, because like <appinfo>, any attributes are permitted on an <annotation> (again, provided non-xml schema namespaced). But it encodes application info without using an <appinfo>, so I'm afraid it would be frowned upon. Would it be?
<xs:annotation myinfo="don't panic"/>
Many thanks for your comments!
Interesting examples of a somewhat "standard" usage of <xs:appinfo> are at http://docstore.mik.ua/orelly/xml/schema/ch14_02.htm and at http://docstore.mik.ua/orelly/xml/schema/ch15_01.htm#ch15-77057
Note that <xs:appinfo> should contain information to be processed by an application, not human readable notes (use <xs:documentation> for this).
I don't think that you are hearing anything because I don't think that these annotations are that commonly used, and the whole point of the spec is to allow anyone to put anything that helps them in there.
The only convention I've seen is XHTML documentation, which of course doesn't look like any of your options.
You might look into whether processing libraries like Apache XmlSchema treat all of your options equivalently.
Related
hello, my first question is how I can place cases to better readability? I want to make this diagram fit on a A4-sized paper.
But I am aware that this diagram may be badly made, so I ask you to advice, maybe I should share on the smaller part?
You need to to connect a use case only to its primary actor. So eventually you have to create a common role where the UC is used by this common actor role. Then your specific actors inherit from this common one. Like in #Amir's example International Student inherits from Student.
I'd simply up-vote the latter example but it has <<include>>/<<extend>> which is no favorable with use case synthesis. Moreover it uses a generalization which is very bad practice with UCs since a UC represent an individual added value and inheritance from added value does not make sense (unlike in a class context).
I don't understood your language (In your use-cases). Generally most of time we have some common feature so You can use inheritance in UML diagram. For example if you have different kinds of students (or Actors) that have some common feature you can do something like below picture:
I think there is too many of use cases. I had the same problem. Try using CRUD - https://books.google.co.uk/books?id=gKHfVZn1CkgC&pg=PA367&lpg=PA367&dq=crud+use+cases&source=bl&ots=g7C2qnzunP&sig=F3OtpNWT29NFyqFvmO-MBtTG98k&hl=en&sa=X&ved=0ahUKEwjAmKifh9_OAhWpCsAKHV9pA344ChDoAQg4MAU#v=onepage&q&f=false
Also, you can divide your diagram into few use case diagrams for each actor. Or put all actors on the one side of the diagram and use cases on other. Hope this helps.
I completely agree with the given suggestions (CRUD, inheritance and responsibility by roles) and I additionally recommend not to try to create an overview about the whole universe. Instead, try to separate your use cases into groups based on similarities, differences etc. and explain your modeling on smaller pieces.
Avoid too complex structures and mutual/cyclic dependencies - they are almost always a sign of poor design. Remember, you have to implement and test every connection in your diagram somehow. Less connections, less effort, less errors.
I came across this list of W3C XML Schema: DOs and DON'Ts and the part that says DO NOT use complex types kind of surprises me.
I don't find any trouble in using <xs:complexType name="SomeNewType"> and I don't see why using <xs:group name="someNewElement"> is better than using a complexType.
Should complexType really need to be avoided?
If so, why? What is so problematic about it?
What should be used instead?
For almost any language sufficiently complex and powerful to be interesting, different people will have different views on the best way to use that language.
You ask "should complexType really be avoided?" As you've seen, in the document you point to Kohsuke Kawaguchi (who was a member of the working group that designed XSD and has written several important XSD tools, including one of the first XSD validators) advises users to avoid certain constructs in XSD, including complexType, often on the grounds that the ratio of their advantages to their disadvantages (in particular: their complexity) is poor. You can (and indeed you must) make up your own mind on the persuasiveness of KK's arguments.
Since (as far as I can see) your question amounts to asking "is KK right?", I gather that you don't feel entirely comfortable making up your own mind, or at least that you are curious and want to know what others think.
In general, it's safe to say that many users of XSD, and many creators of XSD tools, disagree with KK. They find the ability to derive complex types from other complex types helpful, and they use it.
It's equally safe to say that many others agree with KK that this or that construct of XSD is too complex and is better avoided. Some who feel this way write documents describing "best practices" which lay out constructs to use and constructs to avoid; sometimes the contents of such documents is useful and sometimes not. Many who agree most fervently with KK about XSD's complex types do not use XSD at all, when they can avoid doing so: they prefer Relax NG (or in some cases, DTDs or Schematron).
In other words: the opinions of qualified observers vary, as do those of unqualified observers. I know some very smart people who disagree with KK on this question. And I also know that KK himself, and some of those who agree with him, are also very smart. I have no intention of choosing a side here.
Finally, you ask If it is problematic, why does it exist in the language construct in the first place? Any construct in any language exists because those who designed the language thought it was worth including. In the case of XSD and complex types, that means: complex types are in XSD as nameable objects because essentially everyone in the responsible working group wanted them in the language. This does not prevent them from being problematic: like everyone else, people of great technical skill can make mistakes, and groups that must seek consensus can under the right circumstances produce designs that no one really likes very much (but which everyone prefers to the alternative of not having the construct in question at all; sometimes compromise is the only way to get something done).
I hope this helps.
I'm looking for a way for my XSD file to validate one field based on the content of another.
For example, it may need to validate that my "start date" field is before my "end date" field.
Is this possible?
Short answer: No, you can't do it with what you refer to "XSD" and probably means W3C XML Schema 1.0
Long answer:
You CAN validate such things with RelaxNG + Schematron or if it has to be XSD, use W3C schema 1.1 with it's assertion mechanism. Version 1.1 is currently in a Candidate Release phase so not a full recommendation, so you tools probably don't support that yet.
On a more philosophical level, you might want to consider whether weaving such fine-grained business rules is a right approach. I am currently involved in several standards and in those standards, I make sure it's the end user application that validates such business rules - it's too broad for a standard schema to define things in such detail, the schema would be too big, verbose, have a too steep learning curve and be much harder to maintain.
i need to write a schema that all xml instances are valid to it.
i tried:
<xs:element name="Arguments">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
</xs:complexType>
but it enforces a root element named Arguments.
is there a way for the root to be Any ?
Good question, although I am not sure it can be done. Your approach with using xs:any is good but I'm not sure it can be applied for an entire XML (i.e. the root) but just for a section of it.
To quote from a book I once read (something that puts a purpose on the "why?" people are asking): [...] useful when writing schemas for languages such as XSLT that routinely include markup from multiple vocabularies that are unknown when the schema is written [...] useful when you're just beginning to design the document structure and you don't yet have a clear picture of how everything fits together [...] (XML in a nutshell)
I'm also curious to see if it can be done or what is the best workaround for this.
The whole purpose of a schema is to constrain the potential space of valid documents. Either you're doing a whole document or you're doing a fragment. If you're doing a whole document, the correct approach is to just omit the schema entirely. Really. You've got no constraints at all (other than well-formedness) and so can't apply any interpretation to the document beyond it being an XML document.
The case where you've got a fragment is much more useful though. The best way of doing that is to have an outer element (whose name you control) that contains the uncontrolled fragment. When you do that, you need to say that the content is a sequence of zero-to-unbounded numbers of arbitrary elements, which is what you've done already. If it's really anything, you might also consider allowing mixed content (don't do that if you don't need it, of course, but if you're willing to handle things like XHTML in-paragraph content then that's what you require) and allowing arbitrary attributes on the containing element (see <xsd:anyAttribute>). It's also often a good idea to specify that there are constraints on what namespace the arbitrary elements can come from (##other being the most useful since it stops uncontrolled recursion in your schema).
So, apart from reviewing whether you've got the details right, you're probably best not trying to handle absolutely anything. Just make sure that your container element is defined right for your actual purpose.
I have this big huge XSD which contains many complex elements.
I want to split this huge XSD into smaller XSDs, containing the complex elements as standalone XSDs.
Are there any tools for this?
Altova's XmlSpy doesn't provide an automated splitter but its graphical interface does allow you to copy/paste your types and elements easily from one XSD to another.