From 2a004064f675e97a2889752da349f9a0098e4a2e Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Mon, 26 Oct 2015 19:57:27 +0100 Subject: [PATCH] DOM project solution --- Doc/Sda1/dom.xml | 53 +++++-------------- Doc/Sda1/fo.xml | 4 +- Doc/Sda1/sax.xml | 4 +- Doc/lectures.xml | 9 ++-- P/Sda1/Jdom/StructTitle/.gitignore | 5 ++ P/Sda1/Jdom/StructTitle/pom.xml | 31 +++++++++++ .../src/main/java/dom/CreateExtended.java | 36 +++++++++++++ .../StructTitle/src/main/resources/log4j2.xml | 21 ++++++++ P/pom.xml | 3 ++ ws/Docbook/Config/xxe6/spell/dict_en.txt | 1 + 10 files changed, 120 insertions(+), 47 deletions(-) create mode 100644 P/Sda1/Jdom/StructTitle/.gitignore create mode 100644 P/Sda1/Jdom/StructTitle/pom.xml create mode 100644 P/Sda1/Jdom/StructTitle/src/main/java/dom/CreateExtended.java create mode 100644 P/Sda1/Jdom/StructTitle/src/main/resources/log4j2.xml diff --git a/Doc/Sda1/dom.xml b/Doc/Sda1/dom.xml index 0f8267199..c3ec4a796 100644 --- a/Doc/Sda1/dom.xml +++ b/Doc/Sda1/dom.xml @@ -331,10 +331,10 @@ public class CreateDoc { <question> <label>Creation of an extended XML document instance</label> - <para>In order to run the examples given during the lecture the - <filename - xlink:href="http://www.jdom.org/downloads">jdom2.jar</filename> - library must be added to the <envar>CLASSPATH</envar>.</para> + <para>In order to run the examples the <filename + xlink:href="http://www.jdom.org/downloads">jdom2</filename> + library must be configured in your project's + <filename>pom.xml</filename>.</para> <para>The <acronym xlink:href="http://www.w3.org/DOM">DOM</acronym> creating example @@ -350,34 +350,9 @@ public class CreateDoc { </question> <answer> - <programlisting language="java">package dom; -... -public class CreateExtended { - /** - * @param args - * @throws IOException - */ - public static void main(String[] args) throws IOException { - - final Element titel = new Element("titel"), - tLong = new Element("long"), - tShort = new Element("short"); - - <emphasis role="bold">// Append <long> and <short> to parent <title></emphasis> - titel.addContent(tLong).addContent(tShort); - - <emphasis role="bold">// Append text to <long> and <short></emphasis> - tLong.addContent(new Text("The long version of this title")); - tShort.addContent(new Text("Short version")); - - <emphasis role="bold">// Set formatting for the XML output</emphasis> - Format outFormat = Format.getPrettyFormat(); - - <emphasis role="bold">// Serialize to console</emphasis> - final XMLOutputter printer = new XMLOutputter(outFormat); - printer.output(titel, System.out); - } -}</programlisting> + <annotation> + <para>P/Sda1/Jdom/StructTitle</para> + </annotation> </answer> </qandaentry> </qandadiv> @@ -494,7 +469,7 @@ Article: 200W Stereo Amplifier, order number: 9921</programlisting> <question> <label>Simple HTML output</label> - <para>Instead exporting simple text output in <xref + <para>Instead of exporting simple text output in <xref linkend="domTreeTraversal"/> we may also create HTML pages like:</para> @@ -523,12 +498,12 @@ Article: 200W Stereo Amplifier, order number: 9921</programlisting> </body> </html></programlisting> - <para>Instead of simply writing - <code>...println(<html>\n\t<head>...)</code> - statements you are expected to code a more sophisticated solution. - We may combine<xref linkend="createDocModify"/> and <xref - linkend="createDocModify"/>. The idea is reading the XML catalog - instance as a <acronym + <para>Rather then + coding<code>...println(<html>\n\t<head>...)</code> + statements you are expected to implement a more sophisticated + solution. We may combine<xref linkend="createDocModify"/> and + <xref linkend="createDocModify"/>. The idea is reading the XML + catalog instance as a <acronym xlink:href="http://www.w3.org/DOM">DOM</acronym> as before. Then construct a <emphasis>second</emphasis> <acronym xlink:href="http://www.w3.org/DOM">DOM</acronym> tree for the diff --git a/Doc/Sda1/fo.xml b/Doc/Sda1/fo.xml index e03e1c67a..a66292816 100644 --- a/Doc/Sda1/fo.xml +++ b/Doc/Sda1/fo.xml @@ -1,4 +1,4 @@ - <chapter xml:id="fo" version="5.0" xmlns="http://docbook.org/ns/docbook" + <section xml:id="fo" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg" @@ -1302,5 +1302,5 @@ leader-pattern="dots"/>C<fo:leader leader-pattern="dots"/>D</fo:bloc </qandadiv> </qandaset> </section> - </chapter> + </section> diff --git a/Doc/Sda1/sax.xml b/Doc/Sda1/sax.xml index e6a670326..d840fab23 100644 --- a/Doc/Sda1/sax.xml +++ b/Doc/Sda1/sax.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<chapter version="5.0" xml:id="sax" xmlns="http://docbook.org/ns/docbook" +<section version="5.0" xml:id="sax" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg" @@ -1764,4 +1764,4 @@ Namespace '<emphasis role="bold">http://www.w3.org/1999/XSL/Transform</emphasis> </qandadiv> </qandaset> </section> -</chapter> +</section> diff --git a/Doc/lectures.xml b/Doc/lectures.xml index eab1bc632..484101777 100644 --- a/Doc/lectures.xml +++ b/Doc/lectures.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <book version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg" xmlns:m="http://www.w3.org/1998/Math/MathML" @@ -68,20 +69,20 @@ <xi:include href="Sda1/xslt.xml" xpointer="element(/1)"/> - <xi:include href="Sda1/sax.xml" xpointer="element(/1)"/> - <xi:include href="Sda1/dom.xml" xpointer="element(/1)"/> <xi:include href="Sda1/jdbc.xml" xpointer="element(/1)"/> <xi:include href="Sda1/jpaintro.xml" xpointer="element(/1)"/> - <xi:include href="Sda1/fo.xml" xpointer="element(/1)"/> - <appendix> <title>Appendix</title> <xi:include href="Sda1/vaadin.xml" xpointer="element(/1)"/> + + <xi:include href="Sda1/sax.xml" xpointer="element(/1)"/> + + <xi:include href="Sda1/fo.xml" xpointer="element(/1)"/> </appendix> </part> diff --git a/P/Sda1/Jdom/StructTitle/.gitignore b/P/Sda1/Jdom/StructTitle/.gitignore new file mode 100644 index 000000000..4ef0c0524 --- /dev/null +++ b/P/Sda1/Jdom/StructTitle/.gitignore @@ -0,0 +1,5 @@ +/target/ +/.settings/ +A1.log +.classpath +.project diff --git a/P/Sda1/Jdom/StructTitle/pom.xml b/P/Sda1/Jdom/StructTitle/pom.xml new file mode 100644 index 000000000..9694d925d --- /dev/null +++ b/P/Sda1/Jdom/StructTitle/pom.xml @@ -0,0 +1,31 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>de.hdm-stuttgart.mi</groupId> + <artifactId>lecturenotes-pom</artifactId> + <version>1.0</version> + + <relativePath>../../../pom.xml</relativePath> + </parent> + + <groupId>de.hdm-stuttgart.mi.sda1</groupId> + <artifactId>structtitle</artifactId> + <version>0.8</version> + <packaging>jar</packaging> + + <name>StructTitle</name> + + <url>http://www.mi.hdm-stuttgart.de/freedocs</url> + + <dependencies> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom2</artifactId> + <version>${org.jdom.jdom2.version}</version> + </dependency> + + </dependencies> +</project> \ No newline at end of file diff --git a/P/Sda1/Jdom/StructTitle/src/main/java/dom/CreateExtended.java b/P/Sda1/Jdom/StructTitle/src/main/java/dom/CreateExtended.java new file mode 100644 index 000000000..ed1b8bc47 --- /dev/null +++ b/P/Sda1/Jdom/StructTitle/src/main/java/dom/CreateExtended.java @@ -0,0 +1,36 @@ +package dom; + +import java.io.IOException; + +import org.jdom2.Element; +import org.jdom2.Text; +import org.jdom2.output.Format; +import org.jdom2.output.XMLOutputter; + +public class CreateExtended { + + /** + * @param args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + + final Element titel = new Element("titel"), + tLong = new Element("long"), + tShort = new Element("short"); + + // Append <long> and <short> to parent <title> + titel.addContent(tLong).addContent(tShort); + + // Append text to <long> and <short> + tLong.addContent(new Text("The long version of this title")); + tShort.addContent(new Text("Short version")); + + // Set formatting for the XML output + Format outFormat = Format.getPrettyFormat(); + + // Serialize to console + final XMLOutputter printer = new XMLOutputter(outFormat); + printer.output(titel, System.out); + } +} diff --git a/P/Sda1/Jdom/StructTitle/src/main/resources/log4j2.xml b/P/Sda1/Jdom/StructTitle/src/main/resources/log4j2.xml new file mode 100644 index 000000000..885670527 --- /dev/null +++ b/P/Sda1/Jdom/StructTitle/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.alignimg.App" level="warn"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="warn"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/P/pom.xml b/P/pom.xml index 2f8402e93..c4210a94e 100644 --- a/P/pom.xml +++ b/P/pom.xml @@ -118,6 +118,9 @@ <module>Sda1/InsertGui/V2</module> <module>Sda1/InsertGui/V4</module> + + <module>Sda1/Jdom/StructTitle</module> + <module>Sda1/Jpa/HibernateStandalone</module> <module>Sda1/NoCast</module> diff --git a/ws/Docbook/Config/xxe6/spell/dict_en.txt b/ws/Docbook/Config/xxe6/spell/dict_en.txt index 12b6e3e2a..568e21c66 100644 --- a/ws/Docbook/Config/xxe6/spell/dict_en.txt +++ b/ws/Docbook/Config/xxe6/spell/dict_en.txt @@ -15,4 +15,5 @@ passphrases plugin plugins pythagorean +serializer Unicode -- GitLab