| folge2 | TMNav | TMHarvest | Panckoucke | Hamburg 2004 |
A template contains elements that describe topicmap objects that you want to create or modify. For example, you can define that an occurrence is added to a certain topic, or you describe an association which shall be created.
A template is processed once for each datarecord that the provider returns.
In each iteration, the placeholders in the template are substituted with concrete value from the current record. Afterwards theese completed elements serve to identify or create topic map objects.
The following strategies are used throughout the template-based harvesting:
Whenever an element stands for a topic or a reference to a topic (this is true for: <topic>, <instanceOf>, <roleSpec> and <player>) you may use one of the identification attributes to lookup an existing topic.
If no topic that matches the given criteria can be found, a new one is created. In this case, the new topic will automatically be populated with a set of characteristics which depend on the match criteria used.
The names of the identification attributes start with the prefix by. The values of the identification attributes may contain placeholders.
The following identification attributes are currently supported:
Identifies a topic by its internal tm4j-id.
If the topic is created by parsing a xtm-source, the tm4j-id equals the id-attribute from the xml-serialisation. If no id-attribute was defined for the topic, tm4j assigns the topic object a new generic id.
If no topic with the given id exists, a new topic is created and the given id is assigned to it. The resourceLocator of the topic is assembled from the baseLocator of the topicmap and the given id, which is used as the fragment-Identifier.
Identifies a topic by the given resourceLocator.
The resourceLocator of a topic is composed of the baseLocator of its parent topicmap and a fragment identifier. The fragment identifier is defined by the id-attribute of the XTM-File (respectively the ID from LTM-File), or maybe by a byID-attribute, if the topic was created by TMHarvest. If no id was around when the topic was created, tm4j did assign a generic id to the topic.
If no topic with the given resourceLocator could be found, a new one is created. The given resourceLocator is assigned to the new topic and the fragment identifier of the locator is used as id.
Identifies a topic by the given subjectIndicator.
If no topic with the given subjectIndicator could be found, TMHarvest creates a new topic. A new id is generated for the topic and the given subjectIndidcator is assigned to the new topic.
Identifies a topic by the given tolog query.
The first column of the query's resultset should refer to a topic. If the query returns more than one row, only the first row is taken into account.
Unlike the other forms of topic idenfication, if the query does not return a topic, TMHarvest does not create a new one.
You may use placeholders in the attributes and in the bodytexts of the template elements. TMHarvest substitutes the placeholders with concrete values in two stages of the harvesting process:
The syntax of the placeholders follow the well-known format "${REF}". "REF" is the name, under which a provider exports a value. The dollar-sign and the braces serves as placeholder identification.
If a placeholders name is not bound to a value in a record, the placeholder remains in the resulting string as a literal, all inclusive the dollar-sign and the braces.
The patterns may contain mixed static and dynamic parts as in the following example "id=${REF}".
Supposed a provider returns as a record two name-value-pairs:
price=23 currency=euro
The pattern:
"Price: ${price} ${currency}"
will be substituted to the following string:
"Price: 23 euro"
Each template element may contain an onError-attribute. With this attribute you define, how TMHarvest reacts if an exception is thrown during the processing of the element's body.
The dtd defines three values, that can be assigned to the onError-attribute.
TMHarvest currently defines the following elements to create or modify topic map objects. The name of the elements follow the XTM-Sytax.
Root element of the template. Contains <topic>- and <association>-elements.
Creates a new topic or modifies an existing one. An existing one ist specified by one of the identification-attributes. If no such topic can be found, a new one is created.
Creates a new association of the (optional) given type and with the specified members. Members and types are specified within child elements.
Creates a subject indicator and adds it to the enclosing topic.
The enclosed text may contain placeholders which are resolved against the current record.
Creates a typing association for the enclosing element.
The topic, which plays the role of class in this association is fetched by using the identifying attributes. If no topic could be found, a new one is created.
Creates a basename and adds it to the enclosing topic.
The enclosed text may contain placeholders which are resolved against the current record.
Creates an occurrence and adds it to the enclosing topic.
Creates an inline-resource and adds it to the enclosing occurrence.
The enclosed text may contain placeholders which are resolved against the current record
Creates a link to an in- or external resource and adds it to the enclosing occurrence.
The enclosed text may contain placeholders which are resolved against the current record
Creates a member elements and adds it ot the enclosig association.
Creates a roleSpec for the enclosing member.
Identifies the role defining topic by the usual attributes.
Creates a player for the enclosing member.
Identifies the role playing topic by the usual attributes.