Commits

Matthias Nüßler committed 93568fa

Move sample XSL and XML files to be included in testutils JAR.

Comments (0)

Files changed (7)

src/main/resources/books.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<books xmlns="http://www.example.org/books">
-    <book id="1">
-        <title>Clean Code: A Handbook of Agile Software Craftsmanship</title>
-        <authors>
-            <author>Robert C. Martin</author>
-        </authors>
-        <pages>464</pages>
-        <publisher>Prentice Hall</publisher>
-        <edition publication-date="August 11, 2008">1</edition>
-        <isbn-10>0132350882</isbn-10>
-    </book>
-    <book id="2">
-        <title>Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation</title>
-        <authors>
-            <author>Jez Humble</author>
-            <author>David Farley</author>
-        </authors>
-        <pages>512</pages>
-        <publisher>Addison-Wesley Professional</publisher>
-        <edition publication-date="August 6, 2010">1</edition>
-        <isbn-10>0321601912</isbn-10>
-    </book>
-    <book id="3">
-        <title>Programming Ruby 1.9: The Pragmatic Programmers' Guide</title>
-        <authors>
-            <author>Dave Thomas</author>
-            <author>Chad Fowler</author>
-            <author>Andy Hunt</author>
-        </authors>
-        <pages>1000</pages>
-        <publisher>Pragmatic Bookshelf</publisher>
-        <edition publication-date="April 28, 2009">3</edition>
-        <isbn-10>1934356085</isbn-10>
-    </book>
-    <book id="4">
-        <title>Web Operations: Keeping the Data On Time</title>
-        <authors>
-            <author>John Allspaw</author>
-            <author>Jesse Robbins</author>
-        </authors>
-        <pages>336</pages>
-        <publisher>O'Reilly Media</publisher>
-        <edition publication-date="June 28, 2010">1</edition>
-        <isbn-10>1449377440</isbn-10>
-    </book>
-    <book id="5">
-        <title>Ruby on Rails 3 Tutorial: Learn Rails by Example</title>
-        <authors>
-            <author>Michael Hartl</author>
-        </authors>
-        <pages>576</pages>
-        <publisher>Addison-Wesley Professional</publisher>
-        <edition publication-date="December 26, 2010">1</edition>
-        <isbn-10>0321743121</isbn-10>
-    </book>
-</books>

src/main/resources/books.xsd

-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/books" xmlns:tns="http://www.example.org/books" elementFormDefault="qualified">
-
-    <!-- definition of simple types -->
-    <simpleType name="isbnType">
-        <restriction base="string">
-            <pattern value="[0-9]{10}" />
-        </restriction>
-    </simpleType>
-
-    <!-- definition of attributes -->
-    <attribute name="id" type="positiveInteger" />
-    <attribute name="publicationDate" type="date" />
-
-    <!-- definition of simple elements -->
-    <element name="title" type="string" />
-    <element name="pages" type="positiveInteger" />
-    <element name="publisher" type="string" />
-    <element name="author" type="string" />
-    <element name="isbn-10" type="tns:isbnType" />
-
-    <!-- definition of complex types -->
-    <complexType name="authorsType">
-        <sequence>
-            <element ref="tns:author" maxOccurs="unbounded" />
-        </sequence>
-    </complexType>
-    <complexType name="editionType">
-        <simpleContent>
-            <extension base="string">
-                <attribute ref="tns:publicationDate" />
-            </extension>
-        </simpleContent>
-    </complexType>
-    <complexType name="bookType">
-        <sequence>
-            <element ref="tns:title" />
-            <element ref="tns:authors" />
-            <element ref="tns:pages" minOccurs="0" />
-            <element ref="tns:edition" minOccurs="0" />
-            <element ref="tns:isbn-10" minOccurs="0" />
-            </
-            <sequence>
-                >
-                <attribute name="id" type="positiveInteger" />
-    </complexType>
-    <complexType name="booksType">
-        <sequence>
-            <element ref="tns:book" maxOccurs="unbounded" />
-        </sequence>
-    </complexType>
-
-    <!-- definition of complex elements -->
-    <element name="authors" type="tns:authorsType" />
-    <element name="edition" type="tns:editionType" />
-    <element name="book" type="tns:bookType" />
-    <element name="books" type="tns:booksType" />
-
-</schema>

src/main/resources/books.xsl

-<?xml version="1.0"?>
-<!--
-
-    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="http://www.example.org/books" xmlns="http://www.w3.org/1999/xhtml">
-
-    <xsl:template match="/">
-        <html>
-            <head>
-                <title>Reading List</title>
-            </head>
-            <body>
-                <xsl:apply-templates />
-            </body>
-        </html>
-    </xsl:template>
-
-    <xsl:template match="b:books">
-        <table>
-            <th>Title</th>
-            <th>Author</th>
-            <th>Pages</th>
-            <th>Publisher</th>
-            <th>Edition</th>
-            <xsl:apply-templates />
-        </table>
-    </xsl:template>
-
-    <xsl:template match="b:book">
-        <xsl:variable name="id">
-            <xsl:value-of select="@id" />
-        </xsl:variable>
-        <tr id="{$id}">
-            <xsl:apply-templates />
-        </tr>
-    </xsl:template>
-
-    <xsl:template match="b:title">
-        <td>
-            <xsl:value-of select="." />
-        </td>
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:authors">
-        <td>
-            <xsl:apply-templates />
-        </td>
-    </xsl:template>
-
-    <xsl:template match="b:author">
-        <xsl:value-of select="." />
-        <br />
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:pages">
-        <td>
-            <xsl:value-of select="." />
-        </td>
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:publisher">
-        <td>
-            <xsl:value-of select="." />
-        </td>
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:edition">
-        <td>
-            <xsl:value-of select="." />
-            <xsl:choose>
-                <xsl:when test=". = '1'">
-                    <xsl:text>st</xsl:text>
-                </xsl:when>
-                <xsl:when test=". = '2'">
-                    <xsl:text>nd</xsl:text>
-                </xsl:when>
-                <xsl:when test="'3'">
-                    <xsl:text>rd</xsl:text>
-                </xsl:when>
-                <xsl:otherwise>
-                    <xsl:text>th</xsl:text>
-                </xsl:otherwise>
-            </xsl:choose>
-            <xsl:text> edition, </xsl:text>
-            <xsl:value-of select="@publication-date" />
-        </td>
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:isbn-10">
-        <td>
-            <xsl:value-of select="." />
-        </td>
-        <xsl:apply-templates />
-    </xsl:template>
-
-    <xsl:template match="b:*">
-    </xsl:template>
-
-</xsl:stylesheet>

src/test/java/org/nuessler/maven/plugin/cakupan/testutil/TransformationTest.java

 public class TransformationTest extends XslTransformationTestCase {
     private static final String TRUE = Boolean.TRUE.toString();
     private static final String SCHEMA_PATH = "/schemas/xhtml/";
+    private static final String TESTUTIL_PATH = "/org/nuessler/maven/plugin/cakupan/testutil";
     private static Map<String, String> systemIdToResource = createSystemIdToResourceMap();
 
     @Override
     protected File getTransformationFile() {
-        return resourceNameToFile("/books.xsl");
+        return resourceNameToFile(TESTUTIL_PATH + "/books.xsl");
     }
 
     @Override
     protected File getXmlInputFile() {
-        return resourceNameToFile("/books.xml");
+        return resourceNameToFile(TESTUTIL_PATH + "/books.xml");
     }
 
     @Override

src/test/resources/org/nuessler/maven/plugin/cakupan/testutil/books.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<books xmlns="http://www.example.org/books">
+    <book id="1">
+        <title>Clean Code: A Handbook of Agile Software Craftsmanship</title>
+        <authors>
+            <author>Robert C. Martin</author>
+        </authors>
+        <pages>464</pages>
+        <publisher>Prentice Hall</publisher>
+        <edition publication-date="August 11, 2008">1</edition>
+        <isbn-10>0132350882</isbn-10>
+    </book>
+    <book id="2">
+        <title>Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation</title>
+        <authors>
+            <author>Jez Humble</author>
+            <author>David Farley</author>
+        </authors>
+        <pages>512</pages>
+        <publisher>Addison-Wesley Professional</publisher>
+        <edition publication-date="August 6, 2010">1</edition>
+        <isbn-10>0321601912</isbn-10>
+    </book>
+    <book id="3">
+        <title>Programming Ruby 1.9: The Pragmatic Programmers' Guide</title>
+        <authors>
+            <author>Dave Thomas</author>
+            <author>Chad Fowler</author>
+            <author>Andy Hunt</author>
+        </authors>
+        <pages>1000</pages>
+        <publisher>Pragmatic Bookshelf</publisher>
+        <edition publication-date="April 28, 2009">3</edition>
+        <isbn-10>1934356085</isbn-10>
+    </book>
+    <book id="4">
+        <title>Web Operations: Keeping the Data On Time</title>
+        <authors>
+            <author>John Allspaw</author>
+            <author>Jesse Robbins</author>
+        </authors>
+        <pages>336</pages>
+        <publisher>O'Reilly Media</publisher>
+        <edition publication-date="June 28, 2010">1</edition>
+        <isbn-10>1449377440</isbn-10>
+    </book>
+    <book id="5">
+        <title>Ruby on Rails 3 Tutorial: Learn Rails by Example</title>
+        <authors>
+            <author>Michael Hartl</author>
+        </authors>
+        <pages>576</pages>
+        <publisher>Addison-Wesley Professional</publisher>
+        <edition publication-date="December 26, 2010">1</edition>
+        <isbn-10>0321743121</isbn-10>
+    </book>
+</books>

src/test/resources/org/nuessler/maven/plugin/cakupan/testutil/books.xsd

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/books" xmlns:tns="http://www.example.org/books" elementFormDefault="qualified">
+
+    <!-- definition of simple types -->
+    <simpleType name="isbnType">
+        <restriction base="string">
+            <pattern value="[0-9]{10}" />
+        </restriction>
+    </simpleType>
+
+    <!-- definition of attributes -->
+    <attribute name="id" type="positiveInteger" />
+    <attribute name="publicationDate" type="date" />
+
+    <!-- definition of simple elements -->
+    <element name="title" type="string" />
+    <element name="pages" type="positiveInteger" />
+    <element name="publisher" type="string" />
+    <element name="author" type="string" />
+    <element name="isbn-10" type="tns:isbnType" />
+
+    <!-- definition of complex types -->
+    <complexType name="authorsType">
+        <sequence>
+            <element ref="tns:author" maxOccurs="unbounded" />
+        </sequence>
+    </complexType>
+    <complexType name="editionType">
+        <simpleContent>
+            <extension base="string">
+                <attribute ref="tns:publicationDate" />
+            </extension>
+        </simpleContent>
+    </complexType>
+    <complexType name="bookType">
+        <sequence>
+            <element ref="tns:title" />
+            <element ref="tns:authors" />
+            <element ref="tns:pages" minOccurs="0" />
+            <element ref="tns:edition" minOccurs="0" />
+            <element ref="tns:isbn-10" minOccurs="0" />
+            </
+            <sequence>
+                >
+                <attribute name="id" type="positiveInteger" />
+    </complexType>
+    <complexType name="booksType">
+        <sequence>
+            <element ref="tns:book" maxOccurs="unbounded" />
+        </sequence>
+    </complexType>
+
+    <!-- definition of complex elements -->
+    <element name="authors" type="tns:authorsType" />
+    <element name="edition" type="tns:editionType" />
+    <element name="book" type="tns:bookType" />
+    <element name="books" type="tns:booksType" />
+
+</schema>

src/test/resources/org/nuessler/maven/plugin/cakupan/testutil/books.xsl

+<?xml version="1.0"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="http://www.example.org/books" xmlns="http://www.w3.org/1999/xhtml">
+
+    <xsl:template match="/">
+        <html>
+            <head>
+                <title>Reading List</title>
+            </head>
+            <body>
+                <xsl:apply-templates />
+            </body>
+        </html>
+    </xsl:template>
+
+    <xsl:template match="b:books">
+        <table>
+            <th>Title</th>
+            <th>Author</th>
+            <th>Pages</th>
+            <th>Publisher</th>
+            <th>Edition</th>
+            <xsl:apply-templates />
+        </table>
+    </xsl:template>
+
+    <xsl:template match="b:book">
+        <xsl:variable name="id">
+            <xsl:value-of select="@id" />
+        </xsl:variable>
+        <tr id="{$id}">
+            <xsl:apply-templates />
+        </tr>
+    </xsl:template>
+
+    <xsl:template match="b:title">
+        <td>
+            <xsl:value-of select="." />
+        </td>
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:authors">
+        <td>
+            <xsl:apply-templates />
+        </td>
+    </xsl:template>
+
+    <xsl:template match="b:author">
+        <xsl:value-of select="." />
+        <br />
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:pages">
+        <td>
+            <xsl:value-of select="." />
+        </td>
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:publisher">
+        <td>
+            <xsl:value-of select="." />
+        </td>
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:edition">
+        <td>
+            <xsl:value-of select="." />
+            <xsl:choose>
+                <xsl:when test=". = '1'">
+                    <xsl:text>st</xsl:text>
+                </xsl:when>
+                <xsl:when test=". = '2'">
+                    <xsl:text>nd</xsl:text>
+                </xsl:when>
+                <xsl:when test="'3'">
+                    <xsl:text>rd</xsl:text>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:text>th</xsl:text>
+                </xsl:otherwise>
+            </xsl:choose>
+            <xsl:text> edition, </xsl:text>
+            <xsl:value-of select="@publication-date" />
+        </td>
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:isbn-10">
+        <td>
+            <xsl:value-of select="." />
+        </td>
+        <xsl:apply-templates />
+    </xsl:template>
+
+    <xsl:template match="b:*">
+    </xsl:template>
+
+</xsl:stylesheet>