1 Востаннє редагувалося User 298 (28.07.2014 07:50:35)

Тема: Потрібна допомога з XSLT

код
<?xml version="1.0" encoding="UTF-8"?>
<!--DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"[url]http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd[/url]"-->
<article>
  <title>XSLT Trainee Test Problem</title>

  <section>
    <title id="chapter-introduction">Introduction</title>

    <para>This document is intended for all people who would like to obtain an
    XSLT Trainee/Developer position at Intelliarts company. The document
    contains a test problem for applicants, a short introduction into DocBook
    and many links to resources where you can learn more about technologies
    you are supposed to work with: XML, XSLT, HTML and so on.</para>

    <para>The test problem contains a few levels. We assume that one week
    should be enough to learn all required technologies and develop a solution
    for the test problem. In case you complete this work faster then you can
    implement solutions for optional and bonus tasks. The more levels you
    complete, the better your chances are.</para>
  </section>

  <section>
    <title>Problem description</title>

    <para>The final goal of the test problem is to create an XSLT
    transformation which converts an XML document into HTML document. With the
    test problem description you get the source of this document in the XML
    format, or strictly speaking in DocBook, which is semantic markup language
    for technical documentation.</para>

    <para>Chapters below contain a brief description of several DocBook
    elements (or group of elements) and a few examples, thus you can easily
    use this document to test your transformation.</para>
  </section>

  <section>
    <title>DocBook elements catalog</title>

    <para>This chapter contains descriptions of the most commonly used DocBook
    elements with samples. We don't consider structural elements like
    <code>book</code>, <code>article</code> or <code>chapter</code>, since for
    the test problem we chose only the <code>article</code> element.</para>

    <section>
      <title>Block-level elements</title>

      <para>Block-level elements in DocBook are elements like paragraphs,
      lists, and so forth. In the result HTML document they are usually
      represented with block-level elements. Next chapters briefly describe
      some of the block-level elements and provide ideas about how they can be
      rendered.</para>

      <section>
        <title>Paragraph element</title>

        <para>Element name: <code>para</code>.</para>

        <para>Description: the <code>para</code> element represents a
        paragraph in the document. Usually this element is rendered as a block
        with padding before and after it.</para>

        <para>Example:</para>

        <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
        eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
        minim veniam, quis nostrud exercitation ullamco laboris nisi ut
        aliquip ex ea commodo consequat. Duis aute irure dolor in
        reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
        pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
        culpa qui officia deserunt mollit anim id est laborum.</para>
      </section>

      <section>
        <title>Ordered list element</title>

        <para>Element name: <code>orderedlist</code>.</para>

        <para>Description: ordered list is a list of items where each list
        item is marked with a number. Ordered lists can be used for describing
        a procedure which contains a number of steps. Ordered list is marked
        with <code>orderedlist</code> element. Every list item in the list is
        represented by the <code>listitem</code> element. Content of each list
        item is wrapped by a <code>para</code> element. Besides, the
        <code>orderedlist</code> element may also contain an optional
        <code>para</code> element in the beginning to describe the content of
        the list.</para>

        <para>Examples.</para>

        <para>The following list is a simple ordered list with four items. By
        default Arabic numbers are used to mark list items.</para>

        <orderedlist>
          <listitem>
            <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
            sed do eiusmod tempor incididunt ut labore et dolore magna
            aliqua.</para>
          </listitem>

          <listitem>
            <para>Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat.</para>
          </listitem>

          <listitem>
            <para>Duis aute irure dolor in reprehenderit in voluptate velit
            esse cillum dolore eu fugiat nulla pariatur.</para>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>
          </listitem>
        </orderedlist>

        <para>The next list has a specific list intro element and 3 steps.
        List intro is a block level element (similar to paragraph) and should
        be appropriately indented (user should see that description
        corresponds to the list).</para>

        <orderedlist>
          <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
          do eiusmod tempor incididunt ut labore et dolore magna
          aliqua.</para>

          <listitem>
            <para>Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat.</para>
          </listitem>

          <listitem>
            <para>Duis aute irure dolor in reprehenderit in voluptate velit
            esse cillum dolore eu fugiat nulla pariatur.</para>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>
          </listitem>
        </orderedlist>

        <para>List elements can contain different block/inline level elements.
        The following list has several different elements inside every item.
        Such example of content shouldn't be a problem if your transformation
        is flexible and expandable.</para>

        <orderedlist>
          <listitem>
            <para>Lorem ipsum dolor sit amet, <keycap>consectetur adipisicing
            elit</keycap>, sed do eiusmod tempor incididunt ut labore et
            dolore magna aliqua.</para>
          </listitem>

          <listitem>
            <para>Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat.</para>

            <para>Duis aute irure dolor in reprehenderit in voluptate velit
            esse cillum dolore eu fugiat nulla pariatur.</para>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>

            <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
            sed do eiusmod tempor incididunt ut labore et dolore magna
            aliqua.</para>

            <itemizedlist>
              <listitem>
                <para>Ut enim ad minim veniam, quis nostrud exercitation
                ullamco laboris nisi ut aliquip ex ea commodo
                consequat.</para>
              </listitem>

              <listitem>
                <para>Duis aute irure dolor in reprehenderit in voluptate
                velit esse cillum dolore eu fugiat nulla pariatur.</para>
              </listitem>
            </itemizedlist>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>
          </listitem>
        </orderedlist>
      </section>

      <section>
        <title>Unordered list element</title>

        <para>Element name: <code>itemizedlist</code>.</para>

        <para>Description: the <code>itemizedlist</code> element is used to
        add a simple unordered list to the document. Each list item is
        represented by a single <code>listitem</code> element. All list item
        content is wrapped by a single <code>para</code> element. Also a list
        may contain an optional para element at the beginning to describe
        contents of the list.</para>

        <para>Formatting: the list should be rendered as a simple bulleted
        list. When a list intro element is available it should be properly
        indented to let user see that it is a part of the list.</para>

        <para>Examples:</para>

        <para>Simple unordered list that contains four items:</para>

        <itemizedlist>
          <listitem>
            <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
            sed do eiusmod tempor incididunt ut labore et dolore magna
            aliqua.</para>
          </listitem>

          <listitem>
            <para>Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat.</para>
          </listitem>

          <listitem>
            <para>Duis aute irure dolor in reprehenderit in voluptate velit
            esse cillum dolore eu fugiat nulla pariatur.</para>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>
          </listitem>
        </itemizedlist>

        <para>Unordered list with a list intro and three list items:</para>

        <itemizedlist>
          <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
          do eiusmod tempor incididunt ut labore et dolore magna
          aliqua.</para>

          <listitem>
            <para>Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat.</para>
          </listitem>

          <listitem>
            <para>Duis aute irure dolor in reprehenderit in voluptate velit
            esse cillum dolore eu fugiat nulla pariatur.</para>
          </listitem>

          <listitem>
            <para>Excepteur sint occaecat cupidatat non proident, sunt in
            culpa qui officia deserunt mollit anim id est laborum.</para>
          </listitem>
        </itemizedlist>

        <para>More complex unordered list where list items contain different
        elements (including nested unordered list):</para>

        <para><itemizedlist>
            <listitem>
              <para>Lorem ipsum dolor sit amet, <keycap>consectetur
              adipisicing elit</keycap>, sed do eiusmod tempor incididunt ut
              labore et dolore magna aliqua.</para>
            </listitem>

            <listitem>
              <para>Ut enim ad minim veniam, quis nostrud exercitation
              ullamcolaboris nisi ut aliquip ex ea commodo consequat.</para>

              <para>Duis aute irure dolor in reprehenderit in voluptate velit
              esse cillum dolore eu fugiat nulla pariatur.</para>
            </listitem>

            <listitem>
              <para>Excepteur sint occaecat cupidatat non proident, sunt in
              culpa qui officia deserunt mollit anim id est laborum.</para>

              <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
              sed do eiusmod tempor incididunt ut labore et dolore magna
              aliqua.</para>

              <itemizedlist>
                <listitem>
                  <para>Ut enim ad minim veniam, quis nostrud exercitation
                  ullamcolaboris nisi ut aliquip ex ea commodo
                  consequat.</para>
                </listitem>

                <listitem>
                  <para>Duis aute irure dolor in reprehenderit in voluptate
                  velit esse cillum dolore eu fugiat nulla pariatur.</para>
                </listitem>
              </itemizedlist>
            </listitem>

            <listitem>
              <para>Excepteur sint occaecat cupidatat non proident, sunt in
              culpa qui officia deserunt mollit anim id est laborum.</para>
            </listitem>
          </itemizedlist></para>
      </section>

      <section>
        <title>Optional block-level elements tasks</title>

        <para>Change your transformation to support different bullets in the
        nested unordered list.</para>

        <para>Extend this document with your own examples, where unordered
        list nesting is higher than 2. Test if your transformation supports
        such lists, modify the transformation if needed.</para>

        <para>Extend this document with your own example, where the ordered
        list contains another ordered list. Test if your transformation
        supports such lists, modify the transformation if needed.</para>

        <para>In the example above change the numbering level scheme for the
        second level list, i.e. 1, 2, 3, 3.1, 3.2, 4 etc</para>
      </section>
    </section>

    <section id="chapter-inline-elements" label="">
      <title id="chapter-inline-elements.title">Inline elements</title>

      <para>Inline-level tags are elements like emphasis, hyperlinks, and so
      forth. They wrap a text within a block-level element. Usually the
      content of these elements is highlighted with a different font
      (different font family, font style, font weight etc).</para>

      <section>
        <title>'command' element</title>

        <para>Element name: <code>command</code>.</para>

        <para>Description: the <code>keycap</code> element represents a text
        printed on a key on a keyboard.</para>

        <para>Formatting: the content of this element should be formatted
        inline, the key caption is usually rendered with bold font.</para>

        <para>Example:</para>

        <para>Press <keycap>F1</keycap> to see a help window.</para>
      </section>

      <section>
        <title>'emphasis' element</title>

        <para>Element name: <code>emphasis</code>.</para>

        <para>Description: the <code>emphasis</code> element provides a method
        for indicating that certain text should be stressed in some
        way.</para>

        <para>Formatting: the content of this element should be formatted
        inline, emphasized text is usually rendered with italic font.</para>

        <para>Example:</para>

        <para>Here is the <emphasis>thing</emphasis> we would like to
        emphasize.</para>
      </section>

      <section>
        <title>Optional inline elements task</title>

        <para>Create a document with a fragment where <code>emphasis</code>
        and <code>keycap</code> elements are combined. Verify if you
        transformation supports them, extend it if needed.</para>
      </section>
    </section>

    <section>
      <title>Link elements</title>

      <para>Link tags are used to create links which lead to another part of
      the document or to any external resource, for example a website.</para>

      <section>
        <title>Internal links</title>

        <para>Element name: <code>link</code>.</para>

        <para>Description: the <code>link</code> element is used to organize
        links to other parts of the document. Links are organized using the
        <code>id</code> attribute. Each DocBook element can have an
        <code>id</code> attribute. To create a link to the particular element
        the <code>linkend</code> attribute value of the <code>link</code>
        element should contain the same value as the <code>id</code> attribute
        of the target element. The text within the <code>link</code> element
        is the link text.</para>

        <para>Formatting: the links text should be rendered with underlined
        font in green color.</para>

        <para>Example:</para>

        <para>Please click <link linkend="chapter-introduction">here</link> to
        go to the Introduction chapter.</para>

        <para>Links without a correct target set, like <link
        linkend="incorrect-target">this</link>, should be highlighted but
        shouldn't take the reader to another place.</para>
      </section>

      <section>
        <title>External links</title>

        <para>Element name: <code>ulink</code>.</para>

        <para>Description: the <code>ulink</code> element is used to organize
        links to external resources, e.g. websites. The <code>url</code>
        attribute of the <code>ulink</code> element should contain an URL of a
        site.</para>

        <para>Formatting: the link text should be rendered with underlined
        font in green color.</para>

        <para>Example:</para>

        <para>Please click <ulink
        url="http://www.docbook.org/tdg/en/html/ulink.html">here</ulink> to
        read more about external links in DocBook.</para>
      </section>

      <section>
        <title>Optional link elements task</title>

        <para>In addition to the general links handling, implement
        <code>endterm</code> attribute support. The <code>endterm</code>
        attribute specifies the location of the text that should be used as a
        link label.</para>

        <para>Example:</para>

        <para>The following link - <link
        endterm="chapter-inline-elements.title"
        linkend="chapter-inline-elements">link example</link> - should have a
        label with text "Inline elements".</para>

        <para>It would also be nice to add support of rendering other inline
        elements inside links (e.g. <code>keycap</code>,
        <code>emphasis</code>).</para>

        <para>Example:</para>

        <para>The following link - <link
        linkend="chapter-inline-elements"><keycap>bold</keycap> or
        <emphasis>italic</emphasis></link> - should be rendered using
        corresponding fonts.</para>
      </section>
    </section>
  </section>

  <section>
    <title>Bonus tasks</title>

    <para>If you manage to complete the basic level transformation faster than
    a week, here you can find a few bonus tasks. The complexity of bonus tasks
    is increased, so it makes sense to work on them in the provided
    order.</para>

    <section>
      <title>Implement table of contents</title>

      <para>Extend the transformation to make it insert the table of contents
      (TOC) in the beginning of the document.</para>

      <orderedlist>
        <listitem>
          <para>TOC should have a list of all sections/titles encountered in
          the document</para>
        </listitem>

        <listitem>
          <para>TOC entries should have appropriate numbering and indentation
          regarding their position in the document hierarchy.</para>
        </listitem>

        <listitem>
          <para>TOC items should be links to the appropriate section/title, so
          when you click a title in the TOC, you are redirected to the
          corresponding section.</para>
        </listitem>
      </orderedlist>
    </section>

    <section>
      <title>Implement multiple HTML page output</title>

      <para>Extend the transformation to make it generate multiple HTML pages
      for the input document.</para>

      <orderedlist>
        <listitem>
          <para>Each document section should be presented as a separate HTML
          page.</para>
        </listitem>

        <listitem>
          <para>There should be an <code>index.html</code> page that contains
          the TOC.</para>
        </listitem>

        <listitem>
          <para>A click on a TOC entry should open the corresponding section
          in the same window</para>
        </listitem>

        <listitem>
          <para>If a section has child sections, then the corresponding page
          should contain mini-TOC names "Child Topics". Mini-TOC should have
          appropriate titles/links of/to child sections.</para>
        </listitem>

        <listitem>
          <para>Each page should have a navigation block at the top with links
          to previous, parent and next sections.</para>
        </listitem>
      </orderedlist>
    </section>
  </section>

  <section>
    <title>Tools</title>

    <para>It doesn't matter which XSLT processor you use. However, we want to
    let you know that we are working in the Java environment and use Saxon
    XSLT processor in most of our projects.</para>

    <para>It would be nice if you provide a simple Ant build which allows you
    to run a transformation.</para>
  </section>

  <section>
    <title>Acceptance criteria</title>

    <para>The acceptance procedure is very simple. We run you transformation
    to transform the source of this document, then review the resulting HTML
    document.</para>

    <para>The transformation should be completed without errors. The resulting
    document should contain all the contents of the original document
    formatted accordingly.</para>
  </section>

  <section>
    <title>Resources</title>

    <para>This chapter contains links to various useful resources you may need
    to learn more about XML, XSLT, HTML and others. You can use any
    information sources you like (not listed here), but we decided to share
    with you some our favourite ones.</para>

    <para>All technologies (except DocBook) you are supposed to learn are
    developed by World Wide Web Consortium (W3C), so you can find a lot of
    information, including specifications and tutorials at the W3C related
    sites:</para>

    <itemizedlist>
      <listitem>
        <para><ulink url="http://www.w3.org/">http://www.w3.org/</ulink> -
        main W3C site where all specifications, a lot of tutorials and links
        to other resources are available;</para>
      </listitem>

      <listitem>
        <para><ulink
        url="http://www.w3schools.com/">http://www.w3schools.com/</ulink> -
        site with a lot of tutorials, examples and useful stuff.</para>
      </listitem>
    </itemizedlist>

    <section>
      <title>XML</title>

      <para>XML (eXtensible Markup Language) is a set of rules for encoding
      documents electronically. It is defined in the XML 1.0 Specification
      produced by the W3C and several other related specifications; all are
      fee-free open standards. You can find a lot of information about XML
      at:</para>

      <itemizedlist>
        <listitem>
          <para><ulink
          url="http://en.wikipedia.org/wiki/XML">http://en.wikipedia.org/wiki/XML</ulink>
          - Wikipedia page about XML, contains basic information about
          XML and a lot of links to useful XML-related resources.</para>
        </listitem>
      </itemizedlist>
    </section>

    <section>
      <title>XSLT</title>

      <para>XSLT (XSL Transformations) is a declarative, XML-based language
      used for the transformation of XML documents into other XML (or non-XML)
      documents.</para>

      <itemizedlist>
        <listitem>
          <para><ulink
          url="http://en.wikipedia.org/wiki/XSLT">http://en.wikipedia.org/wiki/XSLT</ulink>
          - Wikipedia page about XSLT, provides basic information
          about XSLT and a lot links to useful XSLT-related resources.</para>
        </listitem>

        <listitem>
          <para><ulink
          url="http://www.zvon.org/xxl/XSLTutorial/Output_rus/index.htm">http://www.zvon.org/xxl/XSLTutorial/Output_rus/index.htm</ulink>
          - one of the best XSLT tutorials/references with a lot of samples
          (in many languages including Russian).</para>
        </listitem>

        <listitem>
          <para><ulink
          url="http://xmlhack.ru/books/xslt">http://xmlhack.ru/books/xslt</ulink>
          - probably the best book about XSLT in Russian (partially
          available).</para>
        </listitem>
      </itemizedlist>
    </section>

    <section>
      <title>HTML</title>

      <para>HTML, which stands for Hyper Text Markup Language, is the
      predominant markup language for web pages. It provides the means to
      create structured documents by denoting structural semantics for text
      such as headings, paragraphs, lists etc as well as for links, quotes,
      and other items.</para>

      <itemizedlist>
        <listitem>
          <para><ulink url="http://en.wikipedia.org/wiki/HTML">http://en.wikipedia.org/wiki/HTML</ulink> -
          Wikipedia page about HTML, provides basic information about
          HTML and a lot links to useful HTML-related resources.</para>
        </listitem>

        <listitem>
          <para><ulink
          url="http://www.w3schools.com/html/default.asp">http://www.w3schools.com/html/default.asp</ulink> -
          excellent tutorials, online editor which allows you to quickly check
          how things work.</para>
        </listitem>
      </itemizedlist>
    </section>

    <section>
      <title>DocBook</title>

      <para>DocBook is a semantic markup language for technical documentation.
      It was originally intended for writing technical documents related to
      computer hardware and software but it can be used for any other sort of
      documentation.</para>

      <itemizedlist>
        <listitem>
          <para><ulink
          url="http://www.docbook.org/">http://www.docbook.org/</ulink>
          - the official DocBook home page.</para>
        </listitem>

        <listitem>
          <para><ulink
          url="http://en.wikipedia.org/wiki/DocBook">http://en.wikipedia.org/wiki/DocBook</ulink>
          - Wikipedia page about DocBook, provides basic information
          about DocBook and a lot links to useful DocBook-related
          resources.</para>
        </listitem>

        <listitem>
          <para><ulink
          url="http://www.docbook.org/tdg/en/html/docbook.html">http://www.docbook.org/tdg/en/html/docbook.html</ulink>
          - DocBook: The Definitive Guide - very detailed book about DocBook
          format. Best place to search information about any element, DocBook
          document authoring and so on.</para>
        </listitem>
      </itemizedlist>
    </section>
  </section>
</article>

Bartash: код слід брати у теги [ code ]. Великі обсяги коду додатково беруться у тег [ spoiler ].
Ось це потрібно перевести в HTML, можливо хтось зможе підказати як привильно це зробити.

2

Re: Потрібна допомога з XSLT

гляньте сюди - http://codeghar.wordpress.com/2012/02/0 … in-debian/

3

Re: Потрібна допомога з XSLT

яку програму використовувати щоб валідність провірити?

4

Re: Потрібна допомога з XSLT

як бачимо, конвертер консольний, тому читайте man і пишіть bash-скрипт