diff --git a/XmlCross/xmlcross.xml b/XmlCross/xmlcross.xml index e4a6e9efe1d997fb24c96a0ad6530cb359412e37..40e67184fc2f1b01c804f631bb62eed4fb313b32 100644 --- a/XmlCross/xmlcross.xml +++ b/XmlCross/xmlcross.xml @@ -2549,15 +2549,18 @@ xmlns="http://docbook.org/ns/docbook"> <chapter annotations="slide" xml:id="xmlc_chap_transform"> <title>Transforming documents</title> - <figure xml:id="xmlc_fig_problemConvert"> - <title>Format conversion problem</title> + <section xml:id="xmlc_chap_transformHtml"> + <title>Target format <xref linkend="glo_HTML"/></title> - <para>Problem regarding <xref - linkend="xmlc_fig_sourceToMultiFormat"/>:</para> + <figure xml:id="xmlc_fig_problemConvert"> + <title>Format conversion problem</title> - <informaltable border="0"> - <tr> - <td valign="top"><programlisting language="xml"><book version="5.1" ...> + <para>Problem regarding <xref + linkend="xmlc_fig_sourceToMultiFormat"/>:</para> + + <informaltable border="0"> + <tr> + <td valign="top"><programlisting language="xml"><book version="5.1" ...> ... <chapter> <title>Introduction</title> @@ -2565,21 +2568,21 @@ xmlns="http://docbook.org/ns/docbook"> </chapter> ... </book></programlisting></td> - <td valign="top"><programlisting language="xml"><html> + <td valign="top"><programlisting language="xml"><html> <head>...</head> <body> <h1>Introduction</h1> <p>First section.</p> ... </body> </html></programlisting></td> - </tr> - </informaltable> - </figure> + </tr> + </informaltable> + </figure> - <figure xml:id="xmlc_fig_convertByTemplates"> - <title><xref linkend="glo_XSL"/> template rules</title> + <figure xml:id="xmlc_fig_convertByTemplates"> + <title><xref linkend="glo_XSL"/> template rules</title> - <programlisting language="xml"><xsl:template match="/book"> + <programlisting language="xml"><xsl:template match="/book"> <html> <head> ... </head> <body> @@ -2589,53 +2592,53 @@ xmlns="http://docbook.org/ns/docbook"> </body> </html> </xsl:template></programlisting> - </figure> + </figure> - <figure xml:id="xmlc_fig_xsl_para"> - <title>Example: Formatting <tag class="starttag">title</tag> - elements</title> + <figure xml:id="xmlc_fig_xsl_para"> + <title>Example: Formatting <tag class="starttag">title</tag> + elements</title> - <informaltable border="1"> - <tr> - <td rowspan="3"><programlisting language="xml"><xsl:template match="title"> + <informaltable border="1"> + <tr> + <td rowspan="3"><programlisting language="xml"><xsl:template match="title"> <h1> <xsl:value-of select="."/> </h1> </xsl:template></programlisting></td> - <td><programlisting language="xml"><title>Some content</title> </programlisting></td> - </tr> + <td><programlisting language="xml"><title>Some content</title> </programlisting></td> + </tr> - <tr> - <td><para>gets converted to:</para></td> - </tr> + <tr> + <td><para>gets converted to:</para></td> + </tr> - <tr> - <td><programlisting language="xml"><h1>Some content</h1> </programlisting></td> - </tr> - </informaltable> - </figure> + <tr> + <td><programlisting language="xml"><h1>Some content</h1> </programlisting></td> + </tr> + </informaltable> + </figure> - <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_xslMyDocbook"> - <title>Formatting <tag class="starttag">book</tag> instances</title> + <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_xslMyDocbook"> + <title>Formatting <tag class="starttag">book</tag> instances</title> - <qandadiv> - <qandaentry> - <question> - <para>In <xref linkend="xmlc_qandaBookGrammar"/> you developed a - grammar being capable to describe <xref linkend="glo_XML"/> - document instances. This exercise aims at transforming arbitrary - instances into <xref linkend="glo_HTML"/>.</para> + <qandadiv> + <qandaentry> + <question> + <para>In <xref linkend="xmlc_qandaBookGrammar"/> you developed a + grammar being capable to describe <xref linkend="glo_XML"/> + document instances. This exercise aims at transforming arbitrary + instances into <xref linkend="glo_HTML"/>.</para> - <para>Start by reading the beginning of the <link - xlink:href="https://www.w3schools.com/xml/xsl_intro.asp">XSLT - Tutorial</link> and follow the subsequent steps:</para> + <para>Start by reading the beginning of the <link + xlink:href="https://www.w3schools.com/xml/xsl_intro.asp">XSLT + Tutorial</link> and follow the subsequent steps:</para> - <orderedlist> - <listitem> - <para>Provide a reasonable instance example like:</para> + <orderedlist> + <listitem xml:id="xmlc_formattingBookSampleInput"> + <para>Provide a reasonable instance example like:</para> - <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> + <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> <?xml-model href="mybook.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <book> <title>Introducing Java</title> @@ -2673,15 +2676,15 @@ xmlns="http://docbook.org/ns/docbook"> and a compiler.</paragraph> </chapter> </book></programlisting> - </listitem> + </listitem> - <listitem> - <para>Create a <link - xlink:href="https://www.oxygenxml.com/doc/versions/18/ug-editor/topics/defining-new-transformation-scenario.html">XML - Transformation with XSLT</link> starting from the following - skeleton:</para> + <listitem> + <para>Create a <link + xlink:href="https://www.oxygenxml.com/doc/versions/18/ug-editor/topics/defining-new-transformation-scenario.html">XML + Transformation with XSLT</link> starting from the following + skeleton:</para> - <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> + <programlisting language="xml"><?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" @@ -2725,13 +2728,13 @@ xmlns="http://docbook.org/ns/docbook"> </xsl:template> </xsl:stylesheet></programlisting> - </listitem> + </listitem> - <listitem> - <para>Test your transformation. The output should be quite - limited containing only your document's title string:</para> + <listitem> + <para>Test your transformation. The output should be quite + limited containing only your document's title string:</para> - <programlisting language="xml"><html> + <programlisting language="xml"><html> <head> <title>Introducing Java</title> </head> @@ -2739,13 +2742,13 @@ xmlns="http://docbook.org/ns/docbook"> <h1>Introducing Java</h1> </body> </html></programlisting> - </listitem> + </listitem> - <listitem> - <para>Extend the XSL stylesheet in a step- by- step fashion - until finally producing:</para> + <listitem> + <para>Extend the XSL stylesheet in a step- by- step fashion + until finally producing:</para> - <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> + <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> <html> <head> <title>Introducing Java</title> @@ -2784,42 +2787,42 @@ xmlns="http://docbook.org/ns/docbook"> and a compiler.</p> </body> </html></programlisting> - </listitem> - </orderedlist> - - <tip> - <para>Follow the embedded comment hints provided inside the - <xref linkend="glo_XSL"/> skeleton. You'll have to define more - <tag class="starttag">xsl:template match="..."</tag> rules and - <tag class="starttag">xsl:apply-templates ...</tag> calls at - appropriate places.</para> - </tip> - </question> - </qandaentry> - </qandadiv> - </qandaset> - - <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_xslMyDocbookLangColor"> - <title>Providing red background indicating foreign phrases</title> - - <qandadiv> - <qandaentry> - <question> - <para>Extend the previous exercise by providing highlighting to - indicate uses of foreign languages. Let's consider:</para> - - <programlisting language="xml"><paragraph>I am normal</paragraph> <!-- Default language --> -<paragraph lang="rf">Je suis Français</paragraph> <!-- Non-default language --></programlisting> - - <para>The intended output being:</para> - - <programlisting language="xml"><p>I am normal</p> + </listitem> + </orderedlist> + + <tip> + <para>Follow the embedded comment hints provided inside the + <xref linkend="glo_XSL"/> skeleton. You'll have to define more + <tag class="starttag">xsl:template match="..."</tag> rules and + <tag class="starttag">xsl:apply-templates ...</tag> calls at + appropriate places.</para> + </tip> + </question> + </qandaentry> + </qandadiv> + </qandaset> + + <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_xslMyDocbookLangColor"> + <title>Providing red background indicating foreign phrases</title> + + <qandadiv> + <qandaentry> + <question> + <para>Extend the previous exercise by providing highlighting to + indicate uses of foreign languages. Let's consider:</para> + + <programlisting language="xml"><paragraph>I am normal</paragraph> <!-- Default language --> +<paragraph lang="fr">Je suis Français</paragraph> <!-- Non-default language --></programlisting> + + <para>The intended output being:</para> + + <programlisting language="xml"><p>I am normal</p> <p <emphasis role="bold">style="background-color: red;"</emphasis>>Je suis Français</p></programlisting> - <tip> - <para>You may want to define two templates like:</para> + <tip> + <para>You may want to define two templates like:</para> - <programlisting language="xml"><!-- Default language --> + <programlisting language="xml"><!-- Default language --> <xsl:template match="paragraph"> ... </xsl:template> @@ -2829,13 +2832,210 @@ xmlns="http://docbook.org/ns/docbook"> ... </xsl:template></programlisting> - <para>Read the documentation regarding the - <code>paragraph[@lang]</code> XPath syntax.</para> - </tip> - </question> - </qandaentry> - </qandadiv> - </qandaset> + <para>Read the documentation regarding the + <code>paragraph[@lang]</code> XPath syntax.</para> + </tip> + </question> + </qandaentry> + </qandadiv> + </qandaset> + + <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_xslMyDocbookChunk"> + <title>Splitting your document into chunks</title> + + <qandadiv> + <qandaentry> + <question> + <para>Larger documents have to be split up into separate chunks + avoiding too big single page <xref linkend="glo_HTML"/> output. + In our current example each <tag class="starttag">chapter</tag> + shall be written to an individual file + <filename>chunkXY.html</filename>.</para> + + <para>Each chunk will then need a navigation header linking it + to its successor and predecessor. In addition you'll need an + overall <filename>index.html</filename> file containing a table + of contents referencing your chunks.</para> + + <tip> + <para><link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/draft/xslChunking.html">Splitting + documents into chunks</link> is your friend.</para> + </tip> + </question> + </qandaentry> + </qandadiv> + </qandaset> + </section> + + <section xml:id="xmlc_chap_transformPrint"> + <title>Target format print</title> + + <figure xml:id="xmlc_refToFoIntro"> + <title>Basic <xref linkend="glo_FO"/> introduction</title> + + <itemizedlist> + <listitem> + <para>Further reading starting from <link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/draft/foIntro.html">Online + and print versions</link>.</para> + </listitem> + + <listitem> + <para><quote>Hello, world ...</quote> style sample <xref + linkend="glo_FO"/> document.</para> + </listitem> + </itemizedlist> + </figure> + + <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_pureFo"> + <title>Creating a desired <xref linkend="glo_FO"/> target + example</title> + + <qandadiv> + <qandaentry> + <question> + <para>This exercise serves as a prerequisite for generating + printed output for <xref linkend="glo_XML"/> instances based on + your simplified <tag class="starttag">book</tag> schema: As with + the <xref linkend="glo_HTML"/> target format it is a good idea + to have a running example before creating a corresponding <xref + linkend="glo_XSL"/> file in the subsequent exercise <xref + linkend="xmlc_qanda_book2fo"/>.</para> + + <orderedlist> + <listitem> + <para>Create a <xref linkend="glo_FO"/> skeleton file + <filename>book_intended.fo</filename>:</para> + + <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + + <fo:layout-master-set> + <!-- Define a simple page layout --> + <fo:simple-page-master master-name="simplePageLayout" + page-width="60mm" page-height="100mm"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <!-- Print a set of pages using the previously defined layout --> + <fo:page-sequence master-reference="simplePageLayout"> + <fo:flow flow-name="xsl-region-body"> + <fo:block>Introducing Java</fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root></programlisting> + </listitem> + + <listitem> + <para>Configure OxygenXML to transform + <filename>book_intended.fo</filename> to + <filename>book_intended.pdf</filename>.</para> + + <tip> + <itemizedlist> + <listitem> + <para><link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/draft/xml2fo.html">Constructing + <xref linkend="glo_FO"/> from <xref + linkend="glo_XML"/> documents</link></para> + </listitem> + + <listitem> + <para><link + xlink:href="https://www.oxygenxml.com/doc/versions/18/ug-editor/topics/fo-processor-tab-1.html">FO + Processor Tab</link> in Oxygen XML <link + xlink:href="https://www.oxygenxml.com/doc/versions/18/ug-editor/topics/xslt-transformation.html">XSLT + Transformation</link>.</para> + </listitem> + </itemizedlist> + </tip> + </listitem> + + <listitem> + <para>Extend <filename>book_intended.fo</filename> + by:</para> + + <itemizedlist> + <listitem> + <para>Modify the title heading corresponding to <tag + class="starttag">book</tag>/<tag + class="starttag">title</tag> by supplying appropriate + style attributes like e.g. + <property>font-size</property>.</para> + </listitem> + + <listitem> + <para>Add <xref linkend="glo_FO"/> constructs + corresponding to your elements <tag + class="starttag">chapter</tag>, <tag + class="starttag">paragraph</tag>, <tag + class="starttag">itemizedlist</tag> and <tag + class="starttag">listitem</tag> in your <link + linkend="xmlc_formattingBookSampleInput">sample + document</link>. Your final result should result in a + satisfying <xref linkend="glo_PDF"/>.</para> + </listitem> + </itemizedlist> + </listitem> + </orderedlist> + + <tip> + <para>Read the <link + xlink:href="https://freedocs.mi.hdm-stuttgart.de/draft/fo_list.html">Lists + section</link> regarding your <tag + class="starttag">itemizedlist</tag> element.</para> + </tip> + </question> + </qandaentry> + </qandadiv> + </qandaset> + + <qandaset defaultlabel="qanda" xml:id="xmlc_qanda_book2fo"> + <title>Transforming <tag class="starttag">book</tag> instances to + <xref linkend="glo_PDF"/></title> + + <qandadiv> + <qandaentry> + <question> + <para>Write an XSL stylesheet converting <tag + class="starttag">book</tag> instances into <xref + linkend="glo_PDF"/>. Start from the following skeleton file + <filename>book2fo.xsl</filename>:</para> + + <programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml" indent="yes"/> + + <xsl:template match="/book"> + <fo:root> + <fo:layout-master-set> + <fo:simple-page-master master-name="simplePageLayout" + page-width="294mm" page-height="210mm" margin="5mm"> + <fo:region-body margin="15mm"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="simplePageLayout"> + <fo:flow flow-name="xsl-region-body"> + <fo:block font-size="xx-large" font-weight="bold"> + <xsl:value-of select="title"/> + </fo:block> + </fo:flow> + </fo:page-sequence> + </fo:root> + </xsl:template> +</xsl:stylesheet></programlisting> + + <para>Take your result from exercise <xref + linkend="xmlc_qanda_pureFo"/> as a reference.</para> + </question> + </qandaentry> + </qandadiv> + </qandaset> + </section> </chapter> <xi:include href="../Doc/Common/glossary.xml" xpointer="element(/1)"/>