ISO/IEC JTC 1/SC 34N0936
ISO/IEC JTC 1/SC 34
Information Technology --
Document Description and Processing Languages
TITLE: | 13250-4 Topic Maps -- Canonicalization -- Draft |
SOURCE: | Mr. Motomu Naito; Mr. Lars Marius Garshol; Prof. Jaeho Lee |
PROJECT: | FCD 13250-4: Information technology - Topic Maps - Canonicalization |
PROJECT EDITOR: | Mr. Eric Freese; Prof. Jaeho Lee |
STATUS: | Draft |
ACTION: | Review |
DATE: | 2007-11-18 |
DISTRIBUTION: | SC34 and Liaisons |
REPLY TO: |
Dr. James David Mason (ISO/IEC JTC 1/SC 34 Secretariat - Standards Council of Canada) Crane Softwrights Ltd. Box 266, Kars, ON K0A-2E0 CANADA Telephone: +1 613 489-0999 Facsimile: +1 613 489-0995 Network: [email protected] http://www.jtc1sc34.org |
Topic Maps - Canonicalization
Contents
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2.
ISO/IEC 13250-4 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information Technology, Subcommittee SC 34, Document Description and Processing Languages.
ISO/IEC 13250 consists of the following parts, under the general title Topic Maps:
- Part 1: Overview and Basic Concepts
- Part 2: Data Model
- Part 3: XML Syntax
- Part 4: Canonicalization
- Part 5: Reference Model
- Part 6: Compact Topic Maps Syntax
- Part 7: Graphical Notation
Introduction
This part of ISO/IEC13250 defines a format known as Canonical XTM, or CXTM for short. The format is an XML format, and has the property that it guarantees that two equivalent Topic Maps Data Model instances [ISO/IEC 13250-2] will always produce byte-by-byte identical serializations on disk, and that non-equivalent instances will always produce different serializations. CXTM thus enables direct comparison of two topic maps to determine equality by comparison of their canonical serializations.
The purpose of CXTM is to allow the creation of test suites for various Topic Maps-related technologies that are easily portable between different Topic Maps implementations, so long as these support CXTM.
CXTM is not intended to be used for the interchange of topic maps, although this is possible. The standard format for interchange of topic maps is XTM [ISO/IEC 13250-3].
Topic Maps - Canonicalization
1 Scope
This part of ISO/IEC13250 defines the CXTM format, and specifies how CXTM files are produces from topic maps by means of a transformation from the Topic Maps Data Model [ISO/IEC 13250-2] to the XML Infoset [XML Infoset].
2 Normative references
The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
Each of the following documents has a unique identifier that is used to cite the document in the text. The unique identifier consists of the part of the reference up to the first comma.
XML-C14N, Canonical XML, Version 1.0, World Wide Web Consortium, 15th March 2001, http://www.w3.org/TR/2001/REC-xml-c14n-20010315
XML Infoset, XML Information Set, World Wide Web Consortium, 24 October 2001, http://www.w3.org/TR/2001/REC-xml-infoset-20011024
ISO/IEC 13250-2, ISO/IEC 13250-2:2006 Information technology - Topic Maps - Data model
3 Canonicalization
3.1 Introduction
The canonicalization process takes two parameters: a topic map (that is, an instance of the Topic Maps Data Model [ISO/IEC 13250-2]) and a base locator. The process produces a canonicalization of the topic map, with all locators in the topic map rewritten to be relative to the given base locator.
Canonicalization is performed in two steps:
-
A document information item representing the CXTM document is produced from the TMDM instance as described in 3.3.
-
The document information item is serialized to a Canonical XML representation as described in [XML-C14N].
3.2 Notational conventions
Information item properties from [W3C XML-Infoset] are referred to using [[property name]], in order to distinguish them from properties from [ISO/IEC 13250-2].
People found this confusing in 13250-3, because they couldn't tell which properties were XML properties and which were TMDM properties. Should we use the same convention as 13250-3, that is, [[property]] for XML properties?
Throughout the rest of this clause the value of the [parent] property of element information items and attribute information items is not specified. The [parent] property of an element information item must always be set to the element or document information item of which the element information item is a direct child. The [parent] property of an attribute information item must be set to the element information item of which the attribute is a child.
3.3 CXTM Document Information Item
There is exactly one CXTM document information item in the XML Infoset generated by the canonicalization of the Topic Maps Data Model.
The CXTM document information item has the following properties:
-
[[children]] A list containing only the representation of the topic map information item in the Topic Maps Data Model instance
-
[[document element]] The element information item that represents the topic map information item in the Topic Maps Data Model instance
-
[[notations]] The empty set
-
[[unparsed entities]] The empty set
-
[[base URI]] No value
-
[[standalone]] No value
-
[[version]] No value
-
[[all declarations processed]] False
3.4 Constructing a representation of a topic map information item
A topic map information item in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "topicMap"
-
[[children]] A list of element information items in the following order:
-
If the value of the [item identifiers] property of the topic map information item is not the empty set, then a representation of the [item identifiers] property
-
A representation of each topic information item in the [topics] property of the topic map information item in canonical sort order
-
A representation of each association information item in the [associations] property of the topic map information item in canonical sort order
-
-
[[attributes]] If the value of the [reifier] property is not null, then a representation of the [reifier] property otherwise the empty set
3.5 Constructing a representation of a topic item
A topic item is represented by an element information item in the XML Infoset. The element information item has the following properties.
-
[[local name]] The string "topic"
-
[[children]] A list of element information items in the following order:
-
If the value of [subject identifiers] property of the topic item is not the empty set, then an element information item with the following properties:
-
[[local name]] The string "subjectIdentifiers"
-
[[children]] A representation of each of the locator of the [subject identifiers] property in canonical sort order
-
[[attributes]] An empty list
-
-
If the value of the [subject locators] property of the topic item is not the empty set, then an element information item with the following properties:
-
[[local name]] The string "subjectLocators"
-
[[children]] A representation of each of the locator of the [subject locators] property in canonical sort order
-
[[attributes]] An empty list
-
-
If the value of the [item identifiers] property of the topic item is not the empty set, then a representation of the [item identifiers] property
-
A representation of each of the topic name items of the [topic names] property in canonical sort order
-
A representation of each of the occurrence items of the [occurrences] property in canonical sort order
-
For each of the association role items of the [roles played] property in canonical sort order, an element information item with the following properties
-
[[local name]] set to the string "rolePlayed"
-
[[children]] An empty list
-
[[attributes]] A list containing the following attribute information items:
-
[[local name]] set to the string "ref"
-
[[normalized value]] A sequence of character information items representing a string value constructed by the concatenation of:
-
The string "association."
-
The position of the association item which is the value of the [parent] property of the association role item, in the canonically sorted [associations] property of the parent topic map item
NOTE:The position is converted from an integer to a string.
-
The string ".role."
-
The position of the reified association role item in the canonically sorted [roles] property of the parent association item
-
-
-
-
-
[[attributes]] If the value of the [reified] property is not null, then a representation of the [reified] property, otherwise an empty list
3.6 Constructing a representation of the topic name item
Each topic name item in the Topic Maps Data Model is represented by an element information item with the following properties.
-
[[local name]] The string "topicName"
-
[[children]] A list of element information items in the following order:
-
A representation of the [value] property
-
If the value of the [type] property is not null, a representation of the [type] property
-
If the value of the [scope] property is not the empty set, a representation of the [scope] property.
-
A representation of each of the variant items of the [variants] property in canonical sort order
-
If the value of the [item identifiers] property is not the empty set, a representation of the [item identifiers] property
-
-
[[attributes]] If the value of the [reifier] property is not null, a representation of the [reifier] property otherwise an empty list
3.7 Constructing a representation of a variant item
A variant item in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "variant"
-
[[children]] A list of element information items in the following order:
-
If the value of the [value] property is not null, a representation of the [value] property
-
If the value of the [datatype] property is not null, a locator identifying the datatype of the [value] property
-
If the value of the [scope] property is not the empty set, a representation of the [scope] property
-
If the value of the [item identifiers] property is not the empty set, a representation of the [item identifiers] property
-
-
[[attributes]] If the value of the [reifier] property is not null, then a representation of the [reifier] property otherwise an empty list
3.8 Constructing a representation of an occurrence item
An occurrence item in the Topic Maps Data Model is represented by an element information with the following properties:
-
[[local name]] The string "occurrence"
-
[[children]] A list of element information items in the following order:
-
If the value of the [value] property is not null, a representation of the [value] property
-
If the value of the [datatype] property is not null, a locator identifying the datatype of the [value] property
-
If the value of the [type] property is not null, a representation the [type] property
-
If the value of the [scope] property is not the empty set, a representation of the [scope] property
-
If the value of the [item identifiers] property is not the empty set, a representation of the [item identifiers] property
-
-
[[attributes]] If the value of the [reifier] property is not null, a representation of the [reifier] property otherwise an empty list
3.9 Constructing a representation of an association item
An association item in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "association"
-
[[children]] A list of element information items in the following order:
-
If the value of the [type] property is not null, a representation of the [type] property
-
A representation of each of the items of the [roles] property in canonical sort order
-
If the value of the [scope] property is not the empty set, a representation of the [scope] property
-
If the value of the [item identifiers] property is not the empty set, a representation of the [item identifiers] property.
-
-
[[attributes]] If the value of the [reifier] property is not null, then a representation of the [reifier] property otherwise an empty list
3.10 Constructing a representation of the association role item
An association role item in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "role"
-
[[children]] A list of element information items in the following order
-
An element information item with the following properties:
-
[[local name]] The string "player"
-
[[children]] The empty list
-
[[attributes]] A list containing one attribute information item with the following properties:
-
[[local name]] The string "topicref"
-
[[normalized value]] The position of the topic information item that is the value of the encoded property within the canonically sorted list of all topic items in the Topic Maps Data Model being encoded
-
-
-
If the value of the [type] property is not null, a representation of the [type] property
-
If the value of the [item identifiers] property is not the empty set, a representation of the [item identifiers] property
-
-
[[attributes]] If the value of the [reifier] property is not null, a representation of the [reifier] property otherwise an empty list
3.11 Constructing a representation of the [reifier] property
The [reifier] property of a topic map item, topic name item, variant item, occurrence item, association item or association role item is represented as an attribute information item with the following properties:
-
[[local name]] The string "reifier"
-
[[normalized value]] The position of the topic item that is the value of the [reifier] property in the canonically sorted list of all topic items in the Topic Maps Data Model being encoded
3.12 Constructing a representation of the [reified] property
The [reified] property of a topic item is represented as an attribute information item with the following properties:
-
[[local name]] The string "reified"
-
[[normalized value]] A sequence of character information items representing a string value constructed as follows:
-
If the value of the [reified] property is the topic map item, then the string "topicMap"
-
If the value of the [reified] property is a topic name item, then a concatenation of:
-
The string "topic."
-
The position of the topic item, which is the value of the [parent] property of the reified topic name item, within the canonically sorted list of all topic items
-
The string ".name."
-
The position of the topic name item in the canonically sorted [names] property of the parent topic item
-
-
If the value of the [reified] property is a variant item, then a concatenation of:
-
The string "topic."
-
The position of the topic item, which is the value of the [parent] property of the topic name item which is the value of the [parent] property of the reified variant item, within the canonically sorted list of all topic items
-
The string ".name."
-
The position of the topic name item, which is the value of the [parent] property of the reified variant item, in the canonically sorted [names] property of the parent topic item.
-
The string ".variant."
-
The position of the variant item in the canonically sorted [variants] property of the parent topic name item
-
-
If the value of the [reified] property is a occurrence item, then a concatenation of:
-
The string "topic."
-
The position of the topic item, which is the value of the [parent] property of the reified occurrence item, within the canonically sorted list of all topic items
-
The string ".occurrence."
-
The position of the occurrence item in the canonically sorted [occurrences] property of the parent topic item
-
-
If the value of the [reified] property is a association item, then a concatenation of:
-
The string "association."
-
The position of that association item in the canonically sorted [associations] property of the parent topic map item
-
-
If the value of the [reified] property is an association role item, then a concatenation of:
-
The string "association."
-
The position of the association item, which is the value of the [parent] property of the reified association role item, in the canonically sorted [associations] property of the parent topic map item
-
The string ".role."
-
The position of the reified association role item in the canonically sorted [roles] property of the parent association item
-
-
3.13 Constructing a representation of the [scope] property
The [scope] property of a topic name item, variant item, occurrence item or association item is represented by an element information item with the following properties:
-
[[local name]] The string "scope"
-
[[children]] A list of one element information item for each topic item in the value of the [scope] property in canonical sort order. Each element information item has the following properties:
-
[[local name]] The string "scopingTopic"
-
[[children]] An empty list
-
[[attributes]] A list containing a single attribute information item with the following properties:
-
[[local name]] The string "topicref"
-
[[normalized value]] The position of the topic item within the canonically sorted list of all topic items in the Topic Maps Data Model being encoded
-
-
-
[[attributes]] An empty list
3.14 Constructing a representation of the [item identifiers] property
The [item identifiers] property of an information item in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "itemIdentifiers"
-
[[children]] A representation of each of the locator of the [item identifiers] property in canonical sort order
-
[[attributes]] An empty list
3.15 Constructing a representation of the [datatype] property
The [datatype] property of a variant item or occurrence item is represented by an element information item with the following properties:
-
[[local name]] The string "datatype"
-
[[children]] An empty list
-
[[attributes]] A list containing an attribute information item with the following properties:
-
[[local name]] The string "locator"
-
[[normalized value]] A normalized locator that identifies data type.
-
3.16 Constructing a representation of the [type] property
The [type] property of a topic name item, occurrence item, association item or association role item is represented by an element information item with the following properties:
-
[[local name]] The string "type"
-
[[children]] An empty list
-
[[attributes]] A list containing an attribute information item with the following properties:
-
[[local name]] The string "topicref"
-
[[normalized value]] The position of the topic item that is the value of the [type] property within the canonically sorted list of all topic items in the Topic Maps Data Model being encoded.
-
3.17 Constructing a representation of the [value] property
A [value] property in the Topic Maps Data Model is represented by an element information item with the following properties:
-
[[local name]] The string "value"
-
[[children]] A sequence of character information items representing the string value of the [value] property
-
[[attributes]] An empty list
3.18 Encoding of string properties
Before encoding a string property as a sequence of character information items, the string must be normalised according to Unicode Normalization Form C (Unicode Standard Annex #15, Unicode Normalization Forms, [Unicode]). Each character information item must have the following properties:
-
[[character code]] The ISO 10646 ([ISO/IEC 10646-1] and [ISO/IEC 10646-2]) character code for the character.
-
[[element content whitespace]] unknown for whitespace characters (characters with character codes #x20, #x9, #xD and #xA), and false for all other characters.
-
[parent] the containing element or attribute information item.
Should we get rid of the Unicode normalization?
Don't we know for certain that whitespace is not element content whitespace in CXTM?
3.19 Encoding of positional values
When the position of an item in a list is to be encoded, the encoded value is the index of that item in the list counting from 1 as the index of the first list item.
3.20 Default property values for element information items
All element information items created by the canonicalization process must have the following property values:
-
[[namespace name]] No value
-
[[prefix]] No value
-
[[namespace attributes]] The empty set
-
[[in-scope namespaces]] The empty set
-
[[base URI]] No value
-
[parent] The element information item or document information item of which the element is a direct child
3.21 Default property values for attribute information items
All attribute information items created by the canonicalization process must have the following property values:
-
[[namespace name]] No value
-
[[prefix]] No value
-
[[attribute type]] unknown
-
[[references]] unknown
-
[[specified]] the boolean value true
-
[[owner element]]the element information item that this attribute information item belongs to
4 Canonical Sort Order
4.1 Introduction
When transforming an instance of the Topic Maps Data Model to an instance of the XML Infoset model, all properties in the Topic Maps Data Model which are sets of information items must be encoded in the XML Infoset model by encoding each set element in the canonical sort order for the set. The clauses 4.2 to 4.11 define the canonical sort order for each information item type.
4.2 Information Type and Basic Type Sort Order
The following sort order applies to all information items and all instances of the basic types defined by the Topic Maps Data Model.
-
Null
-
string
-
set
-
locator
-
topic map
-
topic
-
topic name
-
variant
-
occurrence
-
association
-
association role
4.3 Comparison of Strings
String values are compared on a character by character basis from the start of the string to the end. When the first pair of characters with different character codes are found, then the string containing the character with the lower code sorts lower than the string containing the character with the higher code. If all pairs compare equal, but one string is shorter than the other, the shortest string sorts lower than the longest string. If no differences are found the two strings are considered equal.
Do we need to consider Unicode normalization here?
4.4 Comparison of Sets
-
Sets sort in order of the number of elements in the collection. A set with fewer elements sorts lower than a set with more elements.
-
For sets of equal size, first sort the elements of each set into their canonical ordering. Starting with the lowest element in each sorted set, perform a pair-wise comparison of element in each collection until a non-equal comparison is found. The collections then sort in the order of the non-equal elements in each collection.
-
Sets with exactly the same elements will be considered equal.
4.5 Comparison Order for Locators
Locators are compared in the same way as strings (see 4.3.
4.6 Canonical Sort Order for Topic Items
Topic items are compared by comparing their properties in the following order.
-
[subject identifiers]
-
[subject locators]
-
[item identifiers]
A combination of these three properties are all that is required to compare two topics. Part 2 of this standard requires that all topic items have at least one value for one of these properties and should two topics match in any one of these three properties, they must be merged.
4.7 Canonical Sort Order for Topic Name Items
Topic name items are compared by comparing their properties in the following order.
-
[value]
-
[type]
-
[scope]
-
[parent]
4.8 Canonical Sort Order for Variant Items
Variant items are compared by comparing their properties in the following order.
-
[value]
-
[datatype]
-
[scope]
-
[parent]
4.9 Canonical Sort Order for Occurrence Items
Occurrence items are compared by comparing their properties in the following order.
-
[value]
-
[datatype]
-
[type]
-
[scope]
-
[parent]
4.10 Canonical Sort Order for Association Items
Association items are compared by comparing their properties in the following order.
-
[type]
-
[roles]
-
[scope]
-
[parent]
4.11 Canonical Sort Order for Association Role Items
Association role items are compared by comparing their properties in the following order.
-
[player]
-
[type]
-
[parent]
5 Normalisation of Locators
This must be completely rewritten.
Whenever the [reference] property of the locator item is used for comparison or for creating values in the XML Infoset instance created by the canonicalization process, it must be first converted to a normalised form.
In the following description of the normalisation procedure for the [reference] property of a locator item, the terms "fragment identifier", "query" and "path segment" are defined in [RFC 3986]
The process of converting the value of the [reference] property of the locator item to its normalised form is as follows:
-
Let the value P be the value of the [reference] property of the locator item with any fragment identifier and query removed and any trailing "/" character removed.
-
If the value of the [reference] property starts with P, then the normalised value of the [reference] property is the substring starting from, and including, the character immediately following the string that matches P, with any leading "/" character removed.
-
If the value of the [reference] property does not start with P and P can be interpreted as a URI with at least one path segment, then remove the last path segment from P and any trailing "/" character and repeat from step (2).
-
If the value of the [reference] property is not modified by the steps above, then the value of the [reference] property is the normalised value of the property.
This process may result in the value of the [reference] property no longer being a syntactically valid or resolvable URI, however the CXTM process described by this part of ISO/IEC13250 does not require a conforming application to dereference these addresses.
A RELAX-NG Schema for CXTM (informative)
topicMap = element topicMap { attlist.reifier, topic*, association* } attlist.reifier &= attribute reifier { xsd:integer }? topic = element topic { attlist.reified, subjectIdentifiers?, subjectLocators?, itemIdentifiers?, topicName*, occurrence*, rolePlayed* } attlist.reified &= attribute reified { text }? subjectIdentifiers = element subjectIdentifiers { locator+ } subjectLocators = element subjectLocators { locator+ } itemIdentifiers = element itemIdentifiers { locator+ } topicName = element topicName { attlist.reifier, value, type?, scope?, variant*, itemIdentifiers? } variant = element variant { attlist.reifier, value?, datatype?, scope?, itemIdentifiers? } occurrence = element occurrence { attlist.reifier, value?, datatype?, type?, scope?, itemIdentifiers? } rolePlayed = element rolePlayed { attribute ref { text } } association = element association { attlist.reifier, type?, role*, scope?, itemIdentifiers? } role = element role { attlist.reifier, player?, type?, itemIdentifiers? } player = element player { attlist.topicref } attlist.topicref &= attribute topicref {xsd:integer} value = element value { text } type = element type { attlist.topicref } locator = element locator { attlist.locator } attlist.locator &= attribute notation { xsd:string }, attribute address { xsd:string } scope = element scope { scopingTopic+ } scopingTopic = element scopingTopic { attlist.topicref } datatype = element datatype { attlist.locator } start = topicMap |