diff --git a/Sda1/Etest/Xslt1/Xslt/person2userTest.xspec b/Sda1/Etest/Xslt1/Xslt/person2userTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..1fe04974ce7dd00c7ce405516ff002398a63c456 --- /dev/null +++ b/Sda1/Etest/Xslt1/Xslt/person2userTest.xspec @@ -0,0 +1,165 @@ +<?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> diff --git a/Sda1/Etest/Xslt1/XsltSolution/.gitignore b/Sda1/Etest/Xslt1/XsltSolution/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0a5ab4b6b5e2a2a9ae934456fc689017373186aa --- /dev/null +++ b/Sda1/Etest/Xslt1/XsltSolution/.gitignore @@ -0,0 +1 @@ +/person2userTest-result.html diff --git a/Sda1/Etest/Xslt1/XsltSolution/.project b/Sda1/Etest/Xslt1/XsltSolution/.project index 27046fa53375f109dad0febf4777bdaeb6311b53..bf2303232ba61d4460d43c8fa4896523f232c287 100644 --- a/Sda1/Etest/Xslt1/XsltSolution/.project +++ b/Sda1/Etest/Xslt1/XsltSolution/.project @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>Xslt</name> + <name>XsltSolution</name> <comment></comment> <projects> </projects> diff --git a/Sda1/Etest/Xslt1/XsltSolution/person.xsd b/Sda1/Etest/Xslt1/XsltSolution/person.xsd index 184586142eb4e06091d54666869972ff84de1186..6d3759cfecbe79b1c7af0b18ef5914d324fb242d 100644 --- a/Sda1/Etest/Xslt1/XsltSolution/person.xsd +++ b/Sda1/Etest/Xslt1/XsltSolution/person.xsd @@ -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> diff --git a/Sda1/Etest/Xslt1/XsltSolution/person2userTest.xspec b/Sda1/Etest/Xslt1/XsltSolution/person2userTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..1fe04974ce7dd00c7ce405516ff002398a63c456 --- /dev/null +++ b/Sda1/Etest/Xslt1/XsltSolution/person2userTest.xspec @@ -0,0 +1,165 @@ +<?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> diff --git a/Sda1/Etest/Xslt1/user.xhtml b/Sda1/Etest/Xslt1/user.xhtml index 1f2ced1da9d86d541ace1bc92b250ba96435b111..83c45756e812ef5387188fd292f16180f1e345ae 100644 --- a/Sda1/Etest/Xslt1/user.xhtml +++ b/Sda1/Etest/Xslt1/user.xhtml @@ -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><person></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><user></code> records.</dd> + + <dt>personData.xml</dt> + + <dd>This is the intended output consisting of + <code><user></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;"><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> diff --git a/Sda1/Etest/Xslt2/exercise1.xhtml b/Sda1/Etest/Xslt2/exercise1.xhtml index e46275aaf4e49535e7c02afdee5bd08431a215a3..b7592bac1754d2d169fd21e50cf9245109f54757 100644 --- a/Sda1/Etest/Xslt2/exercise1.xhtml +++ b/Sda1/Etest/Xslt2/exercise1.xhtml @@ -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><h2></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 diff --git a/Sda1/Etest/Xslt2/exercise2.xhtml b/Sda1/Etest/Xslt2/exercise2.xhtml index c03e261aa7ec8d35fec3e362781cf5137213461a..392b6ec3baadab87969c6ded9981f55ac68d4507 100644 --- a/Sda1/Etest/Xslt2/exercise2.xhtml +++ b/Sda1/Etest/Xslt2/exercise2.xhtml @@ -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><xsl:attributes></code> to supply <code>id</code> values.</li>