Do empty model group definitions in XSD change the defined valid XML language? - xsd

In AUTOSAR_00048.xsd there are many model group definitions with a sequence with no particles, like this:
<xsd:group xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:AR="http://autosar.org/schema/r4.0" name="AR-ELEMENT">
<xsd:sequence/>
</xsd:group>
I don't know if a model group can be extended in some way. But there is definitely no extension of AR-ELEMENT in this XSD.
My question is whether such a "empty" group model changes the sets of XML instances specified by the XSD. Or whether such model group definitions could also be missing and the language determined by the XSD would still be the same.

An empty model group can be deleted without changing the meaning of the XSD model in any way.
There is no extension mechanism for model groups. Sometimes a standards body provides an empty model group as a placeholder for user-defined elements. This ensures that user-defined elements are added in a defined place in the XSD. Not sure whether that is the reason for the empty model groups in your XSD though.

Related

Why is Dita's schema split into topic's and map's?

I'm new to Dita, so I apologize for any ignorance.
I'm using XJC to compile the base (and only the base) Dita 1.3 schema into Java classes. When I attempted to compile all the XSD files, I received errors with elements and groups being redefined. None of the XJC bindings I attempted to write would fix it.
After digging through the schema, I found that mapGrp.xsd/mapMod.xsd and topicGrp.xsd/topicMod.xsd contained the same group and element definitions. This explains why XJC would fail when including all of the XSD files. The XSD parser itself cannot handle these duplicate entries.
So I generated basemap.xsd and basetopic.xsd separately and cleaned up the generated code so I could run a diff against the two directories.
I found that the two schema's have some elements specific to maps and topics. For example, the map schema has DitavalmetaClass and DvrKeyscopePrefixClass while the topic schema doesn't. And the topic schema contains AbstractClass and BodyClass while the map schema doesn't. But the majority of classes are shared between the two schema's.
As for the classes that are shared, there are only three that have some differences between the two schema's (LinktextClass, MetadataClass, and SearchtitleClass). Even then, they aren't big changes, just some differences in what they can contain.
My question is, why couldn't the shared classes go under one common Grp/Mod schema that's shared between topic's and map's and redefine those three classes? Can I change the two schema's so they share the same elements and groups without breaking any of the other schema's that extend the base schema?
Maps and topics are two distinct document types. They share some element types in common but are otherwise completely independent document types.
Note also that DITA does not have "a single grammar" in the way that other XML applications do (or appear to do).
DITA is explicitly architected to allow controlled extension from the base grammars so that you can do any of the following:
Configure a given map or topic type to include or exclude specific elements, either other topic types (in the case of topics) or specific element "domains" (sets of "mix-in" elements). Thus there can be two different working grammars for "topic" documents that allow different sets of elements.
Add "constraint" module that restrict existing content models or attribute lists in some way (for example, disallow a base element type in a specific context).
Define your own new element types and attributes via "specialization"
Thus any attempt to generate things like Java classes or database schemas for DITA in any sort of static way are doomed to fail in the general case.
If you are implementing code that needs to operate on any conforming DITA document then it needs to be more flexible and operate on elements in terms of their #class values, not their tag names.
If it is sensible for you to generate Java classes from the XSDs you must treat each top-level map and topic type (map, bookmap, subjectScheme, learningMap, topic, concept, task, general-task, reference, glossentry, etc.) as a distinct class hierarchy--you cannot combine them in a single hierarchy because they will have different content model rules for the same element types.
You should definitely read the DITA Architecture specification:
http://docs.oasis-open.org/dita/v1.2/os/spec/architectural_specification.html#architectural_specification
Cheers,
Eliot
The DITA 1.3 XML Schemas are not manually put together anymore. They are being generated automatically from Relax NG schemas which are the officially supported schemas by the specification. Maybe you should also take a look at the DITA 1.2 XML Schemas, those were manually written and they might be better modeled to reuse more element definitions.

XML Schema element required depending on enumeration value

Is there a way to require an element depending on the enumeration value entered for another element?
Basically, what I'm trying to do is have an user interface type defined by an enumeration. Depending on the interface type, some fields may or may not be required.
I understand this could be achieved either by making the elements optional, and handling the conditional logic in the Code, or by making different complex types for every possible interface type. However, I want the rules to be apparent to anyone reading the schema, so the Code solution wouldn't be ideal, and adding a ton of complex types, even though they share most of their required fields in common, would add a lot more to the xml parsing logic.
Is it possible to have all this logic contained in the schema to simplify validation and parsing?
This kind of conditional mandatory/optional element inclusion is not possible with XSD.
You can do that using RelaxNG.
You will have a good technical data interface with this kind of schema (describing exactly the structure you want, with a tool like Jing for validation).
And then, if you want to use object mapping, you can use Trang to convert your RelaxNG schema to an XML Schema (the XML Schema will be little more loosy, the true data interface beeing described in RelaxNG).

Auto generate XSD from BPEL? or BPEL from XSD?

So I am new to BPEL, and indeed my XML knowledge is limited (but growing fast as I do this project). I am creating a webservice in BPEL. Now the drag and drop is fine, but what about complex types? I can modify the .xsd file to have them, but do I then need to edit my .wsdl file and .bpel file to match or is there a way to auto generate this to reflect the changes in the .xsd file.
I am using Jdeveloper 10.
Thanks
Not sure about how JDeveloper is dealing with this, but conceptually BPEL only reuses type definitions made in WSDL and/or XSDs that are imported into the BPEL definition. Thus, if you change data types in your schema definitions, the BPEL process with use them accordingly.
To be more concrete, the typical scenario is that you have defined your schema in XSD, import that into your WSDLs and use it to define messages based on your schema. In your BPEL process, you can reference the message types (defined in WSDL) or elements/complexTypes (defined in the XSD).

What's the convention with types and separate XML schema files?

I'm developing a rather large XML Schema to integrate multiple disparate systems. Each system has messages that consist of multiple fields. I've written the schemas so that each field is represented as a type (either simple or complex), while the entire message is represented as an element with a sequence of multiple types.
When defining types using XSD, what is the convention in terms of how you break up your files?
I've been going down the path of having a separate XSD file for each type that I am defining, then a single XSD file that defines the message and imports the required XSD files.
Here's a simplified example showing the structure (can't post images, no reputation).
Type schemas (fields) have a namespace ending in "types", while message schemas have a namespace ending in "messages".
My reasoning was that it would be easier to compose new types using existing types if they were defined in their own file, and that versioning types might be easier.
Is there a better approach? I'm relatively new to XML and Schemas. Thanks in advance.
It makes no sense to have one schema per type. One schema per domain area, yes, but not one per type.
For instance, you might have one schema to define types related to customers, and another schema to define types related to products. You might have a separate schema to define common types like people and addresses, which might be used by the customer schema and also by the product schema (product sales rep, vendor address).
You might combine these in a schema related to order processing, since it involves orders made by customers for products.
Are the separate xsd files you created completely unrelated to eachother? For example if one xsd file handles the sales domain and the other one handles the payments domain, you should give each schema a unique domain specific targetNamespace. This approach is called "Heterogeneous namespace design" and you are using it now. I believe it is best suited for your requirement. Since you are having multiple disparate systems it is better to maintain them in separate xsd files with different targetNamespaces. This enhances re-usability and reduces redundancy of types/fields. It also prevents namespace collisions. However if you have a large number of imports it becomes a challenge to manage and there will be dependency on the granularity of the types defined in the imported schemas.
If they are related to each other you should go for "Homogeneous namespace design".
There are two other approaches for XML Schema design:Homogenous Namespace Design and Chameleon Namespace Design which may not best suit your specific requirement. You can further get details on the benefits/drawbacks of all these three different schema design approaches at http://technologyandleadership.com/three-schema-design-approaches/

Writing annotation schemas for Callisto

Does anybody know where I can find documentation on how to write annotation schemas for Callisto? I'm looking to write something a little more complicated than I can generate from a DTD -- that only gives me the ability to tag different kinds of text mentions. I'm looking to create a schema that represents a single type of relationship between five or six different kinds of textual mentions (and some of these types of mentions have attributes that I need to assign values to), and possibly having a second type of relationship between the first two instances of the first type of relationship.
(Alternatively, does anybody know of any software that would be better for this kind of schema? I've been looking at WordFreak, but it's a little clumsy, and it doesn't support attributes on its textual mentions.)
Creating an XML DTD with one XML tag for each type of textual mention (and attributes on the tags to indicate the attributes), and using an "id" attribute on every tag that the annotator has to fill in himself (a monotonically increasing integer). Then I used the DTD schema generator to create a Callisto schema.

Resources