3

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?

user1428945
  • 339
  • 1
  • 13

2 Answers2

2

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.

Radu Coravu
  • 1,754
  • 1
  • 9
  • 8
2

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

DrMacro
  • 656
  • 3
  • 4