Skip to content
Snippets Groups Projects
Commit 5bd5c9ca authored by Goik Martin's avatar Goik Martin
Browse files

Nex XSL unit test for introductory XSL examination

parent 6e7f68ef
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="person2user.xsl">
<x:scenario label="'person' entry having no contact information">
<x:context>
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</x:context>
<x:expect label="'user' entry having no contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having only 'email'">
<x:context>
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<email>bone@lispy.com</email>
</person>
</x:context>
<x:expect label="'user' entry having only email contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="email">bone@lispy.com</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having only 'phone'">
<x:context select="person">
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<phone>323-433453</phone>
</person>
</x:context>
<x:expect label="'user' entry having phone contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="phone">323-433453</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having 'email' and 'phone'">
<x:context select="person">
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<phone>323-433453</phone>
<email>bone@lispy.com</email>
</person>
</x:context>
<x:expect label="'user' entry having email contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="email">bone@lispy.com</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="One 'person' entry having no id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</persons>
</x:context>
<x:expect label="No 'user' entry at all">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd"/>
</x:expect>
</x:scenario>
<x:scenario label="One 'person' entry having an id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person id='9'>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</persons>
</x:context>
<x:expect label="No 'user' entry at all">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd">
<user index="1" uid="user_9">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
</users>
</x:expect>
</x:scenario>
<x:scenario label="Three 'person' entries, two having an id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person id='9'>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
<person>
<firstName>Sally</firstName>
<lastName>Jones</lastName>
</person>
<person id='7'>
<firstName>Linda</firstName>
<lastName>Evans</lastName>
</person>
</persons>
</x:context>
<x:expect label="Two 'user' entries (one gets filtered)">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd">
<user index="1" uid="user_9">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
<user index="2" uid="user_7">
<uid>Evans</uid>
<fullName>Linda Evans</fullName>
<contact type="none"/>
</user>
</users>
</x:expect>
</x:scenario>
</x:description>
/person2userTest-result.html
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Xslt</name>
<name>XsltSolution</name>
<comment></comment>
<projects>
</projects>
......
......@@ -18,8 +18,8 @@
<xs:sequence>
<xs:element name="firstName"/>
<xs:element name="lastName"/>
<xs:element name="phone" minOccurs="0"/>
<xs:element name="email" minOccurs="0"/>
<xs:element name="phone" minOccurs="0" maxOccurs="1"/>
<xs:element name="email" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="id" type="xs:int" use="optional"/>
</xs:complexType>
......
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="person2user.xsl">
<x:scenario label="'person' entry having no contact information">
<x:context>
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</x:context>
<x:expect label="'user' entry having no contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having only 'email'">
<x:context>
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<email>bone@lispy.com</email>
</person>
</x:context>
<x:expect label="'user' entry having only email contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="email">bone@lispy.com</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having only 'phone'">
<x:context select="person">
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<phone>323-433453</phone>
</person>
</x:context>
<x:expect label="'user' entry having phone contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="phone">323-433453</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="'person' entry having 'email' and 'phone'">
<x:context select="person">
<person id="7">
<firstName>Jim</firstName>
<lastName>Bone</lastName>
<phone>323-433453</phone>
<email>bone@lispy.com</email>
</person>
</x:context>
<x:expect label="'user' entry having email contact information">
<user index="1" uid="user_7">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="email">bone@lispy.com</contact>
</user>
</x:expect>
</x:scenario>
<x:scenario label="One 'person' entry having no id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</persons>
</x:context>
<x:expect label="No 'user' entry at all">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd"/>
</x:expect>
</x:scenario>
<x:scenario label="One 'person' entry having an id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person id='9'>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
</persons>
</x:context>
<x:expect label="No 'user' entry at all">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd">
<user index="1" uid="user_9">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
</users>
</x:expect>
</x:scenario>
<x:scenario label="Three 'person' entries, two having an id">
<x:context >
<persons
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<person id='9'>
<firstName>Jim</firstName>
<lastName>Bone</lastName>
</person>
<person>
<firstName>Sally</firstName>
<lastName>Jones</lastName>
</person>
<person id='7'>
<firstName>Linda</firstName>
<lastName>Evans</lastName>
</person>
</persons>
</x:context>
<x:expect label="Two 'user' entries (one gets filtered)">
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="user.xsd">
<user index="1" uid="user_9">
<uid>Bone</uid>
<fullName>Jim Bone</fullName>
<contact type="none"/>
</user>
<user index="2" uid="user_7">
<uid>Evans</uid>
<fullName>Linda Evans</fullName>
<contact type="none"/>
</user>
</users>
</x:expect>
</x:scenario>
</x:description>
......@@ -13,13 +13,41 @@
href="https://learn.mi.hdm-stuttgart.de/iliasData/goik/sdfweergdth45n3535nr3rn3Gff/xslt.zip">xslt.zip</a>
and import it as a project into your Eclipse workspace.</li>
<li>Your resulting Project named Xslt contains a file
<code>personData.xml</code> and an XSLT skeleton file
<code>person2user.xsl</code>. Define an Xslt transformation scenario
which turns <code>personData.xml</code> into <code>user.xml</code> by
means of <code>person2user.xsl</code>. <span style="color: red;">Do not
overwrite the intended sample output data file
<code>userData.xml</code></span>.</li>
<li><p>Your resulting Project named <code>Xslt</code> contains the
following files:</p><dl>
<dt>person.xsd</dt>
<dd>An XML schema describing a simple XML database containing
<code>&lt;person&gt;</code> records.</dd>
<dt>personData.xml</dt>
<dd>A sample instance being valid with respect to the above
<code>person.xsd</code> schema.</dd>
<dt>person2user.xsl</dt>
<dd>A XSL skeleton setting some transformation related properties
and containing a helper template to identify missing rules.</dd>
<dt>user.xsd</dt>
<dd>An XML schema describing a simple XML database containing
<code>&lt;user&gt;</code> records.</dd>
<dt>personData.xml</dt>
<dd>This is the intended output consisting of
<code>&lt;user&gt;</code> entries being obtained by transforming
<code>personData.xml</code> with (yet incomplete)
<code>person2user.xsl</code>. This shall be valid with respect to
<code>user.xsd</code>.</dd>
<dt>person2userTest.xspec</dt>
<dd>A unit test helping to check <code>person2user.xsl</code> for
correctness.</dd>
</dl></li>
</ol><h2>Description</h2><p>The imported Eclipse project contains the
following sample document instance <code>personData.xml</code>:</p><pre
style="font-family:monospace;">&lt;persons
......@@ -68,7 +96,10 @@
</ul><p>The generated output file shall be valid with respect to
<code>user.xsd</code>.</p><h2>ToDo</h2><p>Start from
<code>person2user.xsl</code> and implement the previously described
transformation. When you are finished upload your final
transformation. Open the unit test file <code>person2userTest.xspec</code>
and hit <code>Apply transformation scenario(s) Xspec for XSLT</code> in the
Eclipse tool bar. This allows to continuously check your progress and
reminds you about possible errors. When you are finished upload your final
<code>person2user.xsl</code> result.</p><h2>Hints</h2><p>The function
<code>position()</code> returns the index of an element within a given node
set.</p></body>
......
......@@ -11,7 +11,7 @@
href="/iliasData/goik/i435uoi6FGbn__JJ34/book2html.zip">book2html.zip</a>
and import it as a project into your Eclipse workspace.</li>
<li><p>Your resulting Project named <code>Xslt</code> contains a
<li><p>Your resulting Project named <code>Book2html</code> contains a
subfolder <code>Book1</code>. This subfolder in turn contains the
following files:</p><dl>
<dt>book.xsd</dt>
......@@ -80,12 +80,13 @@
<li><p><code>chapter/title</code> elements shall be represented by
<code>&lt;h2&gt;</code> tags</p></li>
</ul><h2>ToDo</h2><p>Complete the implementation of
<code>book2html.xsl</code>. Open the unit test file bookBasicTest.xspec and
hit <code>Apply transformation scenario(s) Xspec for XSLT</code> in the
Eclipse tool bar. This allows to continuously check your progress and
reminds you about possible errors. When you are finished upload your final
<code>book2html.xsl</code> result.</p><h2>Hint</h2><p>The XSL unit tests may
contain scenarios not present in your sample files <code>work.xml</code> and
<code>book2html.xsl</code>. Open the unit test file
<code>bookBasicTest.xspec</code> and hit <code>Apply transformation
scenario(s) Xspec for XSLT</code> in the Eclipse tool bar. This allows to
continuously check your progress and reminds you about possible errors. When
you are finished upload your final <code>book2html.xsl</code>
result.</p><h2>Hint</h2><p>The XSL unit tests may contain scenarios not
present in your sample files <code>work.xml</code> and
<code>work.reference.html</code>. So even if your output work.html is
correct for the given sample XML instance your stylesheet may though contain
errors. You may want to open the unit test definitions to find possible
......
......@@ -73,11 +73,11 @@
<code>Book2/book2html.xsl</code>. You may want to start from your XSL result
of the previous exercise by copying relevant content from
<code>Book1/book2html.xsl</code>.</p><p>Open the unit test file
Book2/bookLinkMixedTest.xspec (which imports all tests from the previous
exercise file <code>Book1/bookBasicTest.xspec</code>) and hit <code>Apply
transformation scenario(s) Xspec for XSLT</code> in the Eclipse tool bar.
This allows to continuously check your progress and reminds you about
possible errors. When you are finished upload your final
<code>Book2/bookLinkMixedTest.xspec</code> (which imports all tests from the
previous exercise file <code>Book1/bookBasicTest.xspec</code> as well) and
hit <code>Apply transformation scenario(s) Xspec for XSLT</code> in the
Eclipse tool bar. This allows to continuously check your progress and
reminds you about possible errors. When you are finished upload your final
<code>Book2/book2html.xsl</code> result.</p><h2>Hints:</h2><ul>
<li>Use <code>&lt;xsl:attributes&gt;</code> to supply <code>id</code>
values.</li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment