Family Name First Name Matriculation Number Signature
a) Are the following lines well-formed XML markups (write "yes" or "no" directly behind them)?
<xml> 1 0 1 </lmx> <xm> a b </xm> <a> a b c </a> <a> <a> 1 2 3 </a> b c </a> <a> 1 > 0 < 1 </a> <a n="a b c"> c b c </a> <a id="x"> </b idref="x"> </a> <xsl:template match="address"> </xsl:template> <xsl:template name="factorial"> proceed </xsl:template> <!ELEMENT a (b, c)>
b) This is a DTD for simple (almost natural-language) 'forward' rules and facts:
<!ELEMENT forward ((rule | fact)*)> <!ELEMENT rule (if, then)> <!ELEMENT fact (#PCDATA)> <!ELEMENT if (#PCDATA)> <!ELEMENT then (#PCDATA)>Are the following XML elements valid with respect to this DTD (write "yes" or "no" behind them)?
<forward> </forward>
<forward> the weather </forward>
<forward> <fakt> it snows </fakt> </forward>
<forward> <rule> if it rains then the road gets wet </rule> </forward>
<forward>
<rule>
<if> it rains </if> <then> the road gets wet </then>
</rule>
</forward>
<forward>
<fact> it rains </fact>
<rule>
<if> it rains </if>
<then> the road gets wet </then>
</rule>
</forward>
c) Consider these XML elements for 'forward' (p => c) and 'backward' (c <= p) rules:
<forward> <rule> <if> p </if> <then> c </then> </rule> </forward> <backward> <rule> <conc> c </conc> <prem> p </prem> </rule> </backward>Inductively complete this XML DTD (write into the "..." lines) for 'backward' rules and facts:
<!ELEMENT backward (................)> <!ELEMENT rule (................)> <!ELEMENT ........ (................)> <!ELEMENT ........ (................)> <!ELEMENT ........ (................)>
d) Complete the following XSLT template - by just filling in the "..." versions - for the (XML-to-XML) transformation of 'forward' rules and facts into 'backward' rules and facts:
<xsl:template match="forward">
<........>
<xsl:apply-templates/>
</........>
</xsl:template>
<xsl:template match="rule">
<....>
<....><xsl:value-of select="...."/></....>
. . .
</....>
</xsl:template>
<xsl:template match="fact">
<....>
. . .
</....>
</xsl:template>
Could this transformation be 'inverted' - mapping 'backward' rules and facts into 'forward' rules and facts - without information loss (write in "yes" or "no" here)?
e) This is a RuleML serialization of the implication rule "if it rains then the road gets wet":
<imp>
<_head>
<atom>
<_opr><rel>gets wet</rel></_opr>
<ind>road</ind>
</atom>
</_head>
<_body>
<atom>
<_opr><rel>rains</rel></_opr>
</atom>
</_body>
</imp>
Draw a tree version for it, using role-labeled arcs where possible
(put it next to the serialization).