[sc34wg3] [CTM issue] Consistent name clash handling
Lars Heuer
heuer at semagia.com
Sat Nov 1 14:23:38 EDT 2008
Hi Xuân,
[...]
> When including files, the question arises how to treat name clashes,
> like the following:
> 1. case 1
> * file1.ctm:
> %prefix foo http://bar/1/
> * file2.ctm:
> %prefix foo http://bar/2/
> * file3.ctm:
> %include file1.ctm
> %include file2.ctm
> %prefix foo http://bar/3/
> foo:some_topic
-> foo:sometopic becomes <http://bar/3/some_topic> as you've
mentioned correctly.
> 2. case 2
> * file1.ctm:
> def foo() http://bar1/some_topic end
> * file2.ctm:
> def foo() http://bar2/some_topic end
> * file3.ctm:
> %include file1.ctm
> %include file2.ctm
[...]
> Does case 2 yield a topic map with one topic with
> "http://bar/3/some_topic" as identifier, too?
No. It would be an error. The templates are imported into the local
namespace of file3 and cause a name clash since including file2.ctm
would try do add a template "foo" to "file3.ctm" even if the template
has already been added during the import of "file1.ctm".
> Then, how about this example?
> 1. case 1
> * file1.ctm:
> %prefix foo http://bar/1/
> * file2.ctm:
> %prefix foo http://bar/2/
> * file3.ctm:
> %include file1.ctm
> %include file2.ctm
> foo:some_topic
--> Error, the prefix "foo" is not defined in "file3.ctm"
> 2. case 2
[...]
See the answer to the first "2. case 2".
[...]
> * If two names clash (e.g. in file3.ctm), then o the names are
> retained if their content is the same (for prefixes, if the URL they
> point to is the same, for templates, if their execution would be the
> same, more specifically if their (string) content and scope (e.g.
> what prefixes are valid for them) are the same)
[...]
That's too complicated for templates, imo. Comparing the string
content is too weak. A simple additional whitespace in the template
body would make two template unequal even if they are equal. Comparing
the result of the execution is too complicated. Additionally, the
comparison would slow down the parsing process considerably, I guess.
Imo the include mechanism is not solved optimally, it would have been
better if including would have been removed from or never added to
CTM. In a previous draft we've had a slightly different directive
"%import" which imports just the templates and creates a namespace for
it in the current file. That would have been a simple mechanism to
import templates without name clashes and would have support the
"ontology templates" you have mentioned.
Comparing the content of templates is not optimal, error prone and
complicated. If the current import mechanism is an issue, we should
think about other, simple mechanisms, i.e. the last definition
wins or something like that. Making the include directive more
complicated as it currently is, shouldn't be an option.
Best regards,
Lars
--
Semagia
<http://www.semagia.com>
More information about the sc34wg3
mailing list