Exercise 2; 29-Dec-2000

Knowledge Markup Techniques; Winter 2000

Harold Boley; DFKI, Univ. Kaiserslautern

Suppose some company uses 'flat-address' XML elements of the following form:
<address>
   <name>Xaver M. Linde</name>
   <street>Wikingerufer 7</street> 
   <town>10555 Berlin</town>
</address>
Suppose another company uses 'nested-address' XML elements of the following form:
<address>
   <name>Xaver M. Linde</name>
   <place>
      <street>Wikingerufer 7</street> 
      <town>10555 Berlin</town>
   </place>
</address>

a) Complete the following XSLT template - by just filling in the seven versions of ". . ." - for the (XML-to-XML) transformation of the 'flat-address' form into the 'nested-address' form (thus implementing the tree-transformation rule in the Tutorial on Knowledge Markup Techniques, slide 9):

  <xsl:template match="address">
    <address>
      <. . .><xsl:value-of select=". . ."/></. . .>
      <. . .>
        .   .   .
        .   .   .
      </. . .>
    </address>
  </xsl:template>

b) Try to reconstruct the 'flat-address' form from the 'nested-address' form by some 'inverse' XSLT template.

c) Is there an irrecoverable information loss when applying the XSLT template from a) to the 'flat-address' form? And, when applying the XSLT template from b) to the 'nested-address' form? What would happen when applying the XSLT template from b) to the result of applying the XSLT template from a) to the 'flat-address' form?

d) What kind of template are you using in a) and in b)? Could you have used the respective other kind?

e) Transcribe the 'flat-address' and 'nested-address' forms into a Prolog-like syntax. Reformulate the XSLT templates from a) and b) as Prolog or Relfun rules. Generate their RFML markup. Compare it with the XSLT markup.