<?xml version="1.0" encoding="iso-8859-1"?>
<!-- ============================================================ -->
<!--                                                              -->
<!-- 	This file makes a part of RenderX XSL Test Suite          -->
<!--                                                              -->
<!--    Author: Alexander Peshkov                                 -->
<!--                                                              -->
<!--    (c) RenderX, 2003                                         -->
<!--                                                              -->
<!-- ============================================================ -->
<document>
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns:dc="http://purl.org/dc/elements/1.1/"
           xmlns:dcterms="http://purl.org/dc/terms/"
           xmlns:db="http://www.oasis-open.org/docbook/xml/4.2/">
    <rdf:Description rdf:about="http://xep.xattic.com/testsuite/usecases/svg1.xml">
        <dc:creator>Alexander Peshkov</dc:creator>
        <dc:title>Instream SVG in XSL FO: Tree graphs</dc:title>
        <dc:description>
          <db:para>
            Creates XSL FO document with embedded SVG graphic generated from arbitrary XML data.
            Shows one possible usecase of SVG usage &#8211; generation of tree graphs 
            from phrase constituent structures.
          </db:para>
        </dc:description>
        <dc:date>2003-07-21</dc:date>
        <dcterms:requires rdf:resource="http://xep.xattic.com/testsuite/usecases/generic.xsl"/>
        <dcterms:requires rdf:resource="http://xep.xattic.com/testsuite/usecases/svg1.xsl"/>
    </rdf:Description>
  </rdf:RDF> 
  <title>Create SVG in XSL FO programmatically. Usecase #1: tree-like structures</title>
  <para>
    XSL FO allows you to embed different types of graphic in your documents.
    One of such types is SVG:
    <citation>
      <ulink url="http://www.w3.org/Graphics/SVG/Overview.htm8">Scalabe Vector Graphics (SVG)</ulink>
    </citation>
  </para>
  <para> 
    Apart from common vector graphics advantages
    (such as no-loss quality and relatively small size for certain drawing types) SVG is an XML itself.
    Thus you can not only embed images produced by external applications, but create SVG programmatically 
    from arbitrary XML data by means of XSLT.
    If you have some private data in XML you can present them both in textual and graphical forms
    using single stylesheet that produce XSL FO and SVG.
  </para>
  <para>
    Below we will demonstrate one of possible usecases &#8211; creation of SVG representation 
    of tree-like structure from XML data.  This document contains sentence analysis in the form
    of the following XML:
    <codeblock>
        &lt;S&gt;
          &lt;NP&gt;
            &lt;Det&gt;The&lt;/Det&gt;
            &lt;NP&gt;
              &lt;Adj&gt;quick&lt;/Adj&gt;
              &lt;NP&gt;
                &lt;Adj&gt;brown&lt;/Adj&gt;
                &lt;N&gt;fox&lt;/N&gt;
              &lt;/NP&gt;
            &lt;/NP&gt;
          &lt;/NP&gt;
          &lt;VP&gt;
            &lt;V&gt;jumps&lt;/V&gt;
            &lt;PP&gt;
              &lt;Prep&gt;over&lt;/Prep&gt;
              &lt;NP&gt;
                &lt;Det&gt;a&lt;/Det&gt;
                &lt;NP&gt;
                  &lt;Adj&gt;lazy&lt;/Adj&gt;
                  &lt;N&gt;dog&lt;/N&gt;
                &lt;/NP&gt;
              &lt;/NP&gt;
            &lt;/PP&gt;
          &lt;/VP&gt;
        &lt;/S&gt;
    </codeblock>
  </para>
  <para>  
    Dedicated XSLT stylesheet produces both textual (bracket structure) and graphical (tree-like)
    representation of this data as shown below.
    XSLT stylesheet contains a number of templates, which matches elements mentioned above and produce 
    SVG elements (placed in appropriate SVG namespace <code>xmlns:svg="http://www.w3.org/2000/svg"</code>)
    such as lines and text labels.
    As example, SVG code fragment produced by stylesheet cited below:
    <codeblock>
    &lt;fo:instream-foreign-object width="100%"
                                content-width="scale-to-fit"
                                content-height="100%"&gt;
      &lt;svg:svg width="270pt"
               height="170pt"
               viewBox="0 0 270 160"&gt;
          ...
        &lt;svg:text style="font-family:Helvetica; font-size:10"
                  text-anchor="middle"
                  x="135" y="20"&gt;S&lt;/svg:text&gt;
        &lt;svg:line style="stroke-width:2; stroke: darkred; stroke-linecap: round"
                  x1="135" y1="23" x2="60" y2="30"/&gt;
          ...
      &lt;/svg:svg&gt;
    &lt;/fo:instream-foreign-object&gt;
    </codeblock>
  </para>
  <subtitle>Sentence analysis</subtitle>
  <para>
    <S>
      <NP>
        <Det>The</Det>
        <NP>
          <Adj>quick</Adj>
          <NP>
            <Adj>brown</Adj>
            <N>fox</N>
          </NP>
        </NP>
      </NP>
      <VP>
        <V>jumps</V>
        <PP>
          <Prep>over</Prep>
          <NP>
            <Det>a</Det>
            <NP>
              <Adj>lazy</Adj>
              <N>dog</N>
            </NP>
          </NP>
        </PP>
      </VP>
    </S>
  </para>
</document>