diff --git a/Sda1/Etest/Xslt2/Book2Html/.project b/Sda1/Etest/Xslt2/Book2Html/.project new file mode 100644 index 0000000000000000000000000000000000000000..fe5752ec858298e6f1aacecd651387f428bd996f --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Book2Html</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.oxygenxml.editor.xmlbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.oxygenxml.editor.xmlnature</nature> + </natures> +</projectDescription> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book1/book.xsd b/Sda1/Etest/Xslt2/Book2Html/Book1/book.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2937de43baf54526bc86dfe183f3e22fd2f1b8f5 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book1/book.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" + vc:minVersion="1.0" vc:maxVersion="1.1"> + + <xs:element name="book"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="chapter" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="title" type="xs:string"/> + + <xs:element name="chapter"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element name="para" type="xs:string" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book1/book2html.xsl b/Sda1/Etest/Xslt2/Book2Html/Book1/book2html.xsl new file mode 100644 index 0000000000000000000000000000000000000000..6d07de14a079f8678f4bc9fece8d103c80c734c1 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book1/book2html.xsl @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:output method="xml" indent="yes"/> + <xsl:strip-space elements="*"/> + + + + + <!-- Handling missing templates --> + <xsl:template match="*"> + <p> + <xsl:text>No template defined for element '</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>'</xsl:text> + </p> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Book2Html/Book1/bookBasicTest.xspec b/Sda1/Etest/Xslt2/Book2Html/Book1/bookBasicTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..9fe81d0851bee34e1cfe8910cb04ef01745cfd65 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book1/bookBasicTest.xspec @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + stylesheet="book2html.xsl"> + + <x:scenario label="Testing 'title' being immediate child of 'book'"> + + <x:context select="/book/title"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abcd</title> + <chapter> + <title></title> + <para></para> + </chapter> + </book> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h1' element" > + <h1>Abcd</h1> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing 'title' being immediate child of 'chapter'"> + + <x:context select="/book/chapter/title"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abcd</title> + <chapter> + <title>Defg</title> + <para></para> + </chapter> + </book> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h2' element" > + <h2>Defg</h2> + </x:expect> + + </x:scenario> + + + <x:scenario label="Testing basic 'chapter' structure"> + + <x:context select="/book/chapter"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + <para>Jkl</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting 'h2' containing AbC and two 'p' tags containing X and Y"> + <h2>Def</h2> + <p>Ghi</p> + <p>Jkl</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing multiple 'chapter' nodes"> + + <x:context select="/book/chapter"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + <para>Jkl</para> + </chapter> + <chapter> + <title>Lmn</title> + <para>Opq</para> + <para>Rst</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting 'h2' followed by 'p'. Repetition with corresponding values B and Y"> + + <h2>Def</h2> + <p>Ghi</p> + <p>Jkl</p> + + <h2>Lmn</h2> + <p>Opq</p> + <p>Rst</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing minimal html root skeleton"> + + <x:context> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title/> + <chapter> + <title/> + <para/> + <para/> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting HTML root structure"> + <html> + <head><title/></head> + <body> + <h1/> + <h2/> + <p/> + <p/> + </body> + </html> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing complete example"> + + <x:context> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>AbC</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting HTML root structure"> + <html> + <head> + <title>AbC</title> + </head> + <body> + <h1>AbC</h1> + <h2>Def</h2> + <p>Ghi</p> + </body> + </html> + </x:expect> + + </x:scenario> + +</x:description> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book1/work.reference.html b/Sda1/Etest/Xslt2/Book2Html/Book1/work.reference.html new file mode 100644 index 0000000000000000000000000000000000000000..7f1ae758a5cdd0c6f3c754c3a3e75dda378f9425 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book1/work.reference.html @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<html> + <head> + <title>Beginning XSL</title> + </head> + <body> + <h1>Beginning XSL</h1> + <h2>Basic structure</h2> + <p>An XSLT consists of a stylesheet declaration and a set of templates.</p> + <p>Do not forget: template elements must not be nested!</p> + <h2>Important elements</h2> + <p>Some more text.</p> + <p>The first chapter explains basic structures.</p> + </body> +</html> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book1/work.xml b/Sda1/Etest/Xslt2/Book2Html/Book1/work.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce99efd154ab67f5351d6ad26069e28aa967dba7 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book1/work.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do not forget: template elements must not be nested!</para> + </chapter> + <chapter> + <title >Important elements</title> + <para>Some more text.</para> + <para>The first chapter explains basic structures.</para> + </chapter> +</book> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Book2Html/Book2/book.xsd b/Sda1/Etest/Xslt2/Book2Html/Book2/book.xsd new file mode 100644 index 0000000000000000000000000000000000000000..071d5962a2f91a56d810830099dfc6d3e2f7d71e --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book2/book.xsd @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" + vc:minVersion="1.0" vc:maxVersion="1.1"> + + <xs:element name="book"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="chapter" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="title" type="xs:string"/> + + + <xs:element name="chapter"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="para" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="para" > + <xs:complexType mixed="true"> + <xs:sequence> + <xs:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="link" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="emphasis" type="xs:string"/> + + <xs:element name="link"> + <xs:complexType mixed="true"> + <xs:attribute name="linkend" type="xs:IDREF" use="required"/> + </xs:complexType> + + </xs:element> + +</xs:schema> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book2/book2html.xsl b/Sda1/Etest/Xslt2/Book2Html/Book2/book2html.xsl new file mode 100644 index 0000000000000000000000000000000000000000..e97f87572f1dd6f43267d58047577918bb49cf88 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book2/book2html.xsl @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:output method="xml" indent="yes"/> + <xsl:strip-space elements="*"/> + + + + + + <!-- Handling missing templates --> + <xsl:template match="*"> + <p> + <xsl:text>No template defined for element '</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>'</xsl:text> + </p> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Book2Html/Book2/bookLinkMixedTest.xspec b/Sda1/Etest/Xslt2/Book2Html/Book2/bookLinkMixedTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..38c331527556111f3dc0440ab08eb79c0ae0e6f2 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book2/bookLinkMixedTest.xspec @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + stylesheet="book2html.xsl"> + + + <x:import href="../Book1/bookBasicTest.xspec" /> + + <x:scenario label="Testing @id in 'chapter'"> + + <x:context select="/chapter/title"> + <chapter id='idValue'> + <title>Abc</title> + </chapter> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h2' element"> + <h2 id='idValue'>Abc</h2> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @id in 'para'"> + + <x:context> + <para id='idValue'>Abc</para> + </x:context> + + <x:expect label="'para' text being wrapped in a 'p' element supplying @id"> + <p id='idValue'>Abc</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @id in 'book'"> + + <x:context> + <book id='idValue'> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + </chapter> + </book> + </x:context> + + <x:expect label="Transfer @id value in 'book' to 'body' tag"> + <html> + <head> + <title>Abc</title> + </head> + <body id='idValue'> + <h1>Abc</h1> + <h2>Def</h2> + <p>Ghi</p> + </body> + </html> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing element content of 'emphasis'"> + + <x:context> + <emphasis>AbC</emphasis> + </x:context> + + <x:expect label="'emphasis' text being wrapped in a 'em' element"> + <em>AbC</em> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing 'para' mixed text with 'emphasis'"> + + <x:context> + <para>Some <emphasis>important</emphasis> text</para> + </x:context> + + <x:expect label="'para' components being wrapped in a 'p' element containing 'em'"> + <p>Some <em>important</em> text</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @linkend and element content of 'link'"> + <x:context> + <link linkend='DeF'>AbC</link> + </x:context> + <x:expect label="'link' text being wrapped in a 'a' element providing @href attribute"> + <a href='#DeF'>AbC</a> + </x:expect> + </x:scenario> + + <x:scenario label="Testing mixed 'para' content"> + <x:context> + <para>See <emphasis>important hint</emphasis> in <link linkend='firstChapter'>start chapter</link></para> + </x:context> + <x:expect label="'em' and 'a' tags being wrapped in a 'p' element"> + <p>See <em>important hint</em> in <a href='#firstChapter'>start chapter</a></p> + </x:expect> + </x:scenario> + +</x:description> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Book2Html/Book2/work.reference.html b/Sda1/Etest/Xslt2/Book2Html/Book2/work.reference.html new file mode 100644 index 0000000000000000000000000000000000000000..7c41e75b8fac062826e6ba124732f6c1d56a24a1 --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book2/work.reference.html @@ -0,0 +1,14 @@ +<html> + <head> + <title>Beginning XSL</title> + </head> + <body id="top"> + <h1>Beginning XSL</h1> + <h2 id="firstChapter">Basic structure</h2> + <p>An XSLT consists of a stylesheet declaration and a set of templates.</p> + <p>Do <em>not forget</em>: template elements must not be nested!</p> + <h2>Important elements</h2> + <p id="someText">Some more text.</p> + <p>The <a href="#firstChapter">first chapter</a> explains basic structures.</p> + </body> +</html> diff --git a/Sda1/Etest/Xslt2/Book2Html/Book2/work.xml b/Sda1/Etest/Xslt2/Book2Html/Book2/work.xml new file mode 100644 index 0000000000000000000000000000000000000000..95992573e4b42fdf95e791faa2a51a173f3c17db --- /dev/null +++ b/Sda1/Etest/Xslt2/Book2Html/Book2/work.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter id="firstChapter"> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do <emphasis>not forget</emphasis>: template elements must not be nested!</para> + </chapter> + <chapter> + <title>Important elements</title> + <para id="someText">Some more text.</para> + <para>The <link linkend="firstChapter">first chapter</link> explains basic structures.</para> + </chapter> +</book> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Solution/.project b/Sda1/Etest/Xslt2/Solution/.project new file mode 100644 index 0000000000000000000000000000000000000000..6443cae41350b177650cf9041cab9cf8e31ebfa8 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Solution</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.oxygenxml.editor.xmlbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.oxygenxml.editor.xmlnature</nature> + </natures> +</projectDescription> diff --git a/Sda1/Etest/Xslt2/Solution/Book1/book.xsd b/Sda1/Etest/Xslt2/Solution/Book1/book.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2937de43baf54526bc86dfe183f3e22fd2f1b8f5 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book1/book.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" + vc:minVersion="1.0" vc:maxVersion="1.1"> + + <xs:element name="book"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="chapter" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="title" type="xs:string"/> + + <xs:element name="chapter"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element name="para" type="xs:string" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema> diff --git a/Sda1/Etest/Xslt2/Solution/Book1/book2html.xsl b/Sda1/Etest/Xslt2/Solution/Book1/book2html.xsl new file mode 100644 index 0000000000000000000000000000000000000000..d027423c4fb1f58926e752b22d29d48c0db98501 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book1/book2html.xsl @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:output method="xml" indent="yes"/> + <xsl:strip-space elements="*"/> + + <xsl:template match="/book"> + <html> + <head> + <title> + <xsl:value-of select="title"/> + </title> + </head> + <body> + <xsl:apply-templates/> + </body> + </html> + </xsl:template> + + <xsl:template match="book/title"> + <h1> + <xsl:value-of select="."/> + </h1> + </xsl:template> + + <xsl:template match="chapter/title"> + <h2> + <xsl:value-of select="."/> + </h2> + </xsl:template> + + <xsl:template match="chapter"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="para"> + <p> + <xsl:value-of select="."/> + </p> + </xsl:template> + + <!-- Handling missing templates --> + <xsl:template match="*"> + <p> + <xsl:text>No template defined for element '</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>'</xsl:text> + </p> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Solution/Book1/bookBasicTest.xspec b/Sda1/Etest/Xslt2/Solution/Book1/bookBasicTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..9fe81d0851bee34e1cfe8910cb04ef01745cfd65 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book1/bookBasicTest.xspec @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + stylesheet="book2html.xsl"> + + <x:scenario label="Testing 'title' being immediate child of 'book'"> + + <x:context select="/book/title"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abcd</title> + <chapter> + <title></title> + <para></para> + </chapter> + </book> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h1' element" > + <h1>Abcd</h1> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing 'title' being immediate child of 'chapter'"> + + <x:context select="/book/chapter/title"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abcd</title> + <chapter> + <title>Defg</title> + <para></para> + </chapter> + </book> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h2' element" > + <h2>Defg</h2> + </x:expect> + + </x:scenario> + + + <x:scenario label="Testing basic 'chapter' structure"> + + <x:context select="/book/chapter"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + <para>Jkl</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting 'h2' containing AbC and two 'p' tags containing X and Y"> + <h2>Def</h2> + <p>Ghi</p> + <p>Jkl</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing multiple 'chapter' nodes"> + + <x:context select="/book/chapter"> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + <para>Jkl</para> + </chapter> + <chapter> + <title>Lmn</title> + <para>Opq</para> + <para>Rst</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting 'h2' followed by 'p'. Repetition with corresponding values B and Y"> + + <h2>Def</h2> + <p>Ghi</p> + <p>Jkl</p> + + <h2>Lmn</h2> + <p>Opq</p> + <p>Rst</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing minimal html root skeleton"> + + <x:context> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title/> + <chapter> + <title/> + <para/> + <para/> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting HTML root structure"> + <html> + <head><title/></head> + <body> + <h1/> + <h2/> + <p/> + <p/> + </body> + </html> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing complete example"> + + <x:context> + <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd"> + <title>AbC</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + </chapter> + </book> + </x:context> + + <x:expect label="Expecting HTML root structure"> + <html> + <head> + <title>AbC</title> + </head> + <body> + <h1>AbC</h1> + <h2>Def</h2> + <p>Ghi</p> + </body> + </html> + </x:expect> + + </x:scenario> + +</x:description> diff --git a/Sda1/Etest/Xslt2/Solution/Book1/work.xml b/Sda1/Etest/Xslt2/Solution/Book1/work.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce99efd154ab67f5351d6ad26069e28aa967dba7 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book1/work.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do not forget: template elements must not be nested!</para> + </chapter> + <chapter> + <title >Important elements</title> + <para>Some more text.</para> + <para>The first chapter explains basic structures.</para> + </chapter> +</book> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Solution/Book2/book.xsd b/Sda1/Etest/Xslt2/Solution/Book2/book.xsd new file mode 100644 index 0000000000000000000000000000000000000000..071d5962a2f91a56d810830099dfc6d3e2f7d71e --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book2/book.xsd @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" + vc:minVersion="1.0" vc:maxVersion="1.1"> + + <xs:element name="book"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="chapter" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="title" type="xs:string"/> + + + <xs:element name="chapter"> + <xs:complexType> + <xs:sequence> + <xs:element ref="title"/> + <xs:element ref="para" minOccurs="1" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="para" > + <xs:complexType mixed="true"> + <xs:sequence> + <xs:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="link" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID" use="optional"/> + </xs:complexType> + </xs:element> + + <xs:element name="emphasis" type="xs:string"/> + + <xs:element name="link"> + <xs:complexType mixed="true"> + <xs:attribute name="linkend" type="xs:IDREF" use="required"/> + </xs:complexType> + + </xs:element> + +</xs:schema> diff --git a/Sda1/Etest/Xslt2/Solution/Book2/book2html.xsl b/Sda1/Etest/Xslt2/Solution/Book2/book2html.xsl new file mode 100644 index 0000000000000000000000000000000000000000..943d85f4f642255c8fc2683fb885d335ac368574 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book2/book2html.xsl @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:output method="xml" indent="yes"/> + <xsl:strip-space elements="*"/> + + <xsl:template match="/book"> + <html> + <head> + <title> + <xsl:value-of select="title"/> + </title> + </head> + <body> + <!--Element <book> may contain an @id attribute --> + <xsl:apply-templates select="*|@id"/> + </body> + </html> + </xsl:template> + + <xsl:template match="book/title"> + <h1> + <xsl:value-of select="."/> + </h1> + </xsl:template> + + <xsl:template match="chapter/title"> + <h2> + <!-- Parent element <chapter> may contain an @id attribute --> + <xsl:apply-templates select="text()|parent::chapter/@id"/> + </h2> + </xsl:template> + + <xsl:template match="chapter"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="para"> + <p> + <!-- Element <para> may contain an @id attribute--> + <xsl:apply-templates select="*|text()|@id"/> + </p> + </xsl:template> + + + <xsl:template match="emphasis"> + <em> + <xsl:value-of select="."/> + </em> + </xsl:template> + + <xsl:template match="link"> + <a href='#{@linkend}'> + <xsl:value-of select="."/> + </a> + </xsl:template> + + <xsl:template match="@id"> + <xsl:attribute name="id" select="."/> + </xsl:template> + + + <!-- Handling missing templates --> + <xsl:template match="*"> + <p> + <xsl:text>No template defined for element '</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>'</xsl:text> + </p> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Solution/Book2/bookLinkMixedTest.xspec b/Sda1/Etest/Xslt2/Solution/Book2/bookLinkMixedTest.xspec new file mode 100644 index 0000000000000000000000000000000000000000..f64c5d6c911cfcc6120e34a7aebbe3c0e859ad64 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book2/bookLinkMixedTest.xspec @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + stylesheet="book2html.xsl"> + + + <x:import href="../Book1/bookBasicTest.xspec" /> + + <x:scenario label="Testing @id in 'chapter'"> + + <x:context select="/chapter/title"> + <chapter id='idValue'> + <title>Abc</title> + <para>Def</para> + </chapter> + </x:context> + + <x:expect label="'title' text being wrapped in a 'h2' element"> + <h2 id='idValue'>Abc</h2> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @id in 'para'"> + + <x:context> + <para id='idValue'>Abc</para> + </x:context> + + <x:expect label="'para' text being wrapped in a 'p' element supplying @id"> + <p id='idValue'>Abc</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @id in 'book'"> + + <x:context> + <book id='idValue'> + <title>Abc</title> + <chapter> + <title>Def</title> + <para>Ghi</para> + </chapter> + </book> + </x:context> + + <x:expect label="Transfer @id value in 'book' to 'body' tag"> + <html> + <head> + <title>Abc</title> + </head> + <body id='idValue'> + <h1>Abc</h1> + <h2>Def</h2> + <p>Ghi</p> + </body> + </html> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing element content of 'emphasis'"> + + <x:context> + <emphasis>AbC</emphasis> + </x:context> + + <x:expect label="'emphasis' text being wrapped in a 'em' element"> + <em>AbC</em> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing 'para' mixed text with 'emphasis'"> + + <x:context> + <para>Some <emphasis>important</emphasis> text</para> + </x:context> + + <x:expect label="'para' components being wrapped in a 'p' element containing 'em'"> + <p>Some <em>important</em> text</p> + </x:expect> + + </x:scenario> + + <x:scenario label="Testing @linkend and element content of 'link'"> + <x:context> + <link linkend='DeF'>AbC</link> + </x:context> + <x:expect label="'link' text being wrapped in a 'a' element providing @href attribute"> + <a href='#DeF'>AbC</a> + </x:expect> + </x:scenario> + + <x:scenario label="Testing mixed 'para' content"> + <x:context> + <para>See <emphasis>important hint</emphasis> in <link linkend='firstChapter'>start chapter</link></para> + </x:context> + <x:expect label="'em' and 'a' tags being wrapped in a 'p' element"> + <p>See <em>important hint</em> in <a href='#firstChapter'>start chapter</a></p> + </x:expect> + </x:scenario> + +</x:description> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/Solution/Book2/work.xml b/Sda1/Etest/Xslt2/Solution/Book2/work.xml new file mode 100644 index 0000000000000000000000000000000000000000..8be7f710344e6c574f80e06c9a029d6576aa0923 --- /dev/null +++ b/Sda1/Etest/Xslt2/Solution/Book2/work.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book id="top" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter id="firstChapter"> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do <emphasis>not forget</emphasis>: template elements must not be nested!</para> + </chapter> + <chapter> + <title>Important elements</title> + <para id="someText">Some more text.</para> + <para>The <link linkend="firstChapter">first chapter</link> explains basic structures.</para> + </chapter> +</book> \ No newline at end of file diff --git a/Sda1/Etest/Xslt2/exercise1.xhtml b/Sda1/Etest/Xslt2/exercise1.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..e46275aaf4e49535e7c02afdee5bd08431a215a3 --- /dev/null +++ b/Sda1/Etest/Xslt2/exercise1.xhtml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Exercise 1</title> + </head> + + <body><h2>Objective</h2><p>Development of an XSL stylesheet transforming + valid book style XML instances into HTML.</p><h2>Preparations</h2><ol> + <li>Download <a + 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 + subfolder <code>Book1</code>. This subfolder in turn contains the + following files:</p><dl> + <dt>book.xsd</dt> + + <dd>An XML schema describing simple book type documents</dd> + + <dt>work.xml</dt> + + <dd>A sample instance being valid with respect to the above + <code>book.xsd</code> schema.</dd> + + <dt>book2html.xsl</dt> + + <dd>A XSL skeleton setting some transformation related properties + and containing a helper template to identify missing rules.</dd> + + <dt>work.reference.html</dt> + + <dd>This is the intended output when transforming + <code>work.xml</code> by (yet incomplete) + <code>book2html.xsl</code>.</dd> + + <dt>bookBasicTest.xspec</dt> + + <dd>A unit test helping to check <code>book2html.xsl</code> for + completeness.</dd> + </dl></li> + + <li>Switch to the Oxygenxml perspective and configure a XSL + transformation scenario named <code>book1ToHtml</code> turning + <code>work.xml</code> into <code>work.html</code> by means of + <code>book2html.xsl</code>.</li> + </ol><h2>Description</h2><p>Our sample document instance + <code>work.xml</code> contains:</p><pre style="font-family:monospace;"><book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do not forget: template elements must not be nested!</para> + </chapter> + <chapter> + <title >Important elements</title> + <para>Some more text.</para> + <para>The first chapter explains basic structures.</para> + </chapter> +</book></pre><p>We want to transform this into HTML by means of + <code>book2html.xsl</code> (as being shown in file + <code>work.reference.html</code>):</p><pre style="font-family:monospace;"><html> + <head> + <title>Beginning XSL</title> + </head> + <body> + <h1>Beginning XSL</h1> + <h2>Basic structure</h2> + <p>An XSLT consists of a stylesheet declaration and a set of templates.</p> + <p>Do not forget: template elements must not be nested!</p> + <h2>Important elements</h2> + <p>Some more text.</p> + <p>The first chapter explains basic structures.</p> + </body> +</html></pre><p>The following conditions shall be met:</p><ul> + <li><p><code>book/title</code> elements shall be represented by + <code><h1></code> tags.</p></li> + + <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>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 + errors.</p></body> +</html> diff --git a/Sda1/Etest/Xslt2/exercise2.xhtml b/Sda1/Etest/Xslt2/exercise2.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..5b4f91a4c95da162e2f217a803c015566bd2b763 --- /dev/null +++ b/Sda1/Etest/Xslt2/exercise2.xhtml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Exercise 2</title> + </head> + + <body><h2>Objective</h2><p>Extension of the <code>Book1/book2html.xsl</code> + stylesheet from the previous exercise to accomplish additional + features.</p><h2>Preparations</h2><p>Reuse your current project from the + previous exercise. It contains a second sub folder<code> Book2</code> + offering similar files as before. Configure a second transformation scenario + named book2ToHtml accordingly.</p><h2>Description</h2><p>The current + <code><code>Book2/work.xml</code></code> and <code>Book2/book.xsd</code> + files differ from the previous exercise by:</p><ul> + <li>Allowing <strong>optional</strong> <code>id</code> attributes of + type <code>xs:ID</code> for <code><book></code>, + <code><chapter></code> and <code><para></code> elements</li> + + <li><p>Allowing para elements to be composed of mixed content involving + two new elements:</p><ol> + <li><emphasis> elements to indicate important text + sections.</li> + + <li><code><link linkend="xyz"></code> elements allowing for + document internal links being implemented by <code>xs:ID</code> / + <code>xs:IDREF</code> pairs.</li> + </ol></li> + </ul><pre style="font-family:monospace;"><book ... xsi:noNamespaceSchemaLocation="book.xsd"> + <title>Beginning XSL</title> + <chapter id="firstChapter"> + <title>Basic structure</title> + <para>An XSLT consists of a stylesheet declaration and a set of templates.</para> + <para>Do <emphasis>not forget</emphasis>: template elements must not be nested!</para> + </chapter> + <chapter> + <title>Important elements</title> + <para id="someText">Some more text.</para> + <para>The <link linkend="firstChapter">first chapter</link> explains basic structures.</para> + </chapter> +</book></pre><p>We want to transform instances like the above into HTML + by means of <code>Book2/book2html.xsl</code>. The intended result is being + shown in file <code>Book2/work.reference.html</code>:</p><pre + style="font-family:monospace;"><html> + <head> + <title>Beginning XSL</title> + </head> + <body id="top"> + <h1>Beginning XSL</h1> + <h2 id="firstChapter">Basic structure</h2> + <p>An XSLT consists of a stylesheet declaration and a set of templates.</p> + <p>Do <em>not forget</em>: template elements must not be nested!</p> + <h2>Important elements</h2> + <p id="someText">Some more text.</p> + <p>The <a href="#firstChapter">first chapter</a> explains basic structures.</p> + </body> +</html></pre><p>The following conditions shall be met:</p><ul> + <li><p>Implementing <code>id</code> attributes:</p><ul> + <li><code><book id='xyz'></code> becomes <code><body + id='xyz'></code></li> + + <li><code><chapter id='xyz'></code> becomes <code><h2 + id='xyz'></code></li> + + <li><code><para id='xyz'></code> becomes <code><p + id='xyz'></code></li> + </ul></li> + + <li><p><code><code>xs:IDREF</code> attributes shall be represented by + local HTML references as shown above in <code><a + href="#firstChapter"></code>.</code></p></li> + </ul><h2>ToDo</h2><p>Complete the implementation of + <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/book2html.xsl</code> result.</p><h2>Hints:</h2><ul> + <li>Use <code><xsl:attributes></code> to supply <code>id</code> + values.</li> + + <li>Optional <code>id</code> values may be handled either by + <code><xsl:if></code> statements or by <xsl:apply-templates + select='...|@id'> having a corresponding <code><xsl:template + match='@id'></code> counterpart.</li> + </ul></body> +</html>