OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

dita message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: DITA and Namespaces? A Potential Compromise Solution for DITA 1.3?


Title: DITA and Namespaces? A Potential Compromise Solution for DITA 1.3?
In response to a recent DITA Users posting that happened to have documents that showed specialized elements in a namespace, I was writing that having namespace prefixes caused the problem that namespace prefixes needed to be dereferenced in order to do element-to-type matching. But then I realized that's only true if you want to have your matching defined in terms of namespace names, rather than prefixes. But if you're willing to match on prefixes then everything works except for a single validation edge case, namely determining the that the element type matches a term in the class value when the element's prefix isn't the same as that used in the @class value.

DITA currently has the rule that the tagname must match one of the terms in the @class value. This makes it possible to validate that the element is in fact of a type named in the @class value. For example, given the element:

<foo>

DITA requires that the class value include " module/foo " where "module" could be any module name.

One reason we've said we can't use namespace is because the tagname could have a prefix different from that used in @class value (see example below).

However, that requirement is really only necessary for validation that the element matches its class hierarchy. If we ignored that requirement, then namespaced names in @class would be just as good as unnamespaced names--they would be equally invariant and equally easy to match on using simple string matching.

That leaves the problem of validating that a given element is in fact the element type named in its class value. For example, consider these two elements:

<bar:foo xmlns:bar="http://example.com/ns1"
  class="- topic/topic bar:foo/bar:foo "
>

<foo xmlns="http://example.com/ns1"
  class="- topic/topic bar:foo/bar:foo "
>

Both elements are of the same type--{http://example.com/ns1}:foo--but the first one satisfies the DITA "tagname matches class" rule and the second does not.

To enable complete validation of the type to the class, we would need a separate DITA-specific namespace declaration, e.g.:

<foo xmlns="http://example.com/ns1"
 xmlns:dita_ns="http://oasis-open.org/DITA/namespace/DITA-ns-prefix-binding"
 dita_ns:bar="http://example.com/ns1"
 class="- topic/topic bar:foo/bar:foo "
>

Where the @dita_ns:bar attribute is binding the prefix "bar" as used in the @class attribute.

You can't simply also declare the prefix "bar" on the <foo> element because the prefix may already be bound to a different namespace, e.g.:

<foo xmlns="http://example.com/ns1"
  xmlns:bar="http://example.org/ns2"
  dita_ns:bar="http://example.com/ns1"
  class="- topic/topic bar:foo/bar:foo "
>

Emphasizing that in the general case you cannot predict or control what namespace bindings will be used in a given XML instance.

This suggests to me that for DITA 1.3 we might be able to relax the namespace use rules a bit if we did the following:

1. Allowed the use of namespaced specializations under the following conditions:

A. The tagname is an exact match to a term in the @class value, e.g. "bar:foo" in the example above. This is the case where the prefix used in the @class value is also declared on the element and is, presumably, the namespace intended by specializer. That is, in this case we assume that the document matches the specialization intent without bothering to validate it. This will cover 90% of the cases where in fact namespace prefixes are preserved and the document is correct.

B. The local name matches the local name of the last term in the @class value, e.g. "foo" in the example above. This doesn't catch the case where the element is in fact not in the same namespace as that bound to the prefix in @class, but we could say that for DITA 1.x that's user error and don't do that. This would catch 9 of the remaining 10% of cases, that is, where an editor or other processor moves the namespace binding from a prefix to being the default namespace (the second form of the bar:foo element shown above). Again, there's no validation that the element really is in the same namespace as bound to the prefix used in the @class value, we're just assuming it's correct because usually it will be.

C. Add a DITA-specific prefix-binding attribute like the dita_ns:* attribute shown above for those cases where there is a requirement to completely validate elements to @class prefix bindings. It would be optional in that its use would be optional and conforming processors would not be required to implement it. But it would be easy enough to implement in XSLT 2 or Schematron, so I wouldn't be concerned about having at least one available implementation.

This would all be in advance of a more complete namespace solution in DITA 2.0, where presumably matching is done entirely in terms of namespace names, not prefixes.

I'm pushing on this only because it seems a little weak to have to say that DITA can't use namespaces for what seems, upon analysis, to be a pretty minor technicality that, in practice, has little value in day-to-day practice.

Does this analysis make any sense?

Cheers,

E.
--
Eliot Kimber
Senior Solutions Architect, RSI Content Solutions
"Bringing Strategy, Content, and Technology Together"
Main: 512.554.9368
www.rsicms.com
www.rsuitecms.com
Book: DITA For Practitioners, from XML Press, http://xmlpress.net/publications/dita/practitioners-1/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]