<?xml version="1.0" encoding="UTF-8"?>
<page>
  <created-at type="datetime">2008-11-07T12:23:17Z</created-at>
  <description>Reverted to revision #2</description>
  <id type="integer">93</id>
  <name>ODFXSLTRunnerExamples</name>
  <number type="integer">10</number>
  <person-id type="integer">12</person-id>
  <text>= ODF XSLT Runner and ODF XSLT Runner Task Examples =

__TOC__

The '''samle_xslt''' folder contained in the [http://odftoolkit.org/sources/odf-xslt-Runner-src/show source code] of the ODF XSLT Runner project contains several example XSLT style sheets.

The '''build_xref.xml''' file contained in the  [[ODF XSLT Runner]] project contains several targets that run these style sheets using '''ODF XSLT Runner'''.

The '''build_xref.xml''' file contained in the  [[ODF XSLT Runner Task]] project contains several targets that run these style sheets using '''ODF XSLT Runner Task'''.

== create_flat_schema.xsl  ==

This XSLT style sheets converts an ODF schema into a simplified &quot;flat&quot; variant by resolving Relax-NG &lt;tt&gt;ref&lt;/tt&gt; elements and by making several other simplifications. 

The resulting &quot;flat schema&quot; contains all &lt;tt&gt;element&lt;/tt&gt; elements as children of the &lt;tt&gt;grammar&lt;/tt&gt; element, regardless whether these may occur on top level or not. These element have  &lt;tt&gt;attribute&lt;/tt&gt; child elements for all attributes that may be used with the element, and optionally &lt;tt&gt;element&lt;/tt&gt; elements for all child elements.

The resulting schema is not equivalent to the source schema, and it must not be used for validating documents. Instead its purpose is to provide a basis for creating cross references regarding the ODF specification.  

This stylesheet does neither take an ODF document as input nor does it produce one. It therfore can be called by an usual XSLT processor.  It may also be called by odfxsltrunner using the following command line:

 java -jar odfxsltrunner.jar create_flat_schema.xsl -i &lt;(strict) ODF schema-file&gt; -o &lt;flat ODF schema file&gt;

The following paramters control the conversion:

{|- border=&quot;1&quot;
!name
!values
!description
|-
|&lt;tt&gt;incl-default-values&lt;/tt&gt;
|'''&lt;tt&gt;true&lt;/tt&gt;''',&lt;tt&gt;false&lt;/tt&gt;
|If &lt;tt&gt;true&lt;/tt&gt;, default values specified by &lt;tt&gt;a:defaultValue&lt;/tt&gt; attributes are preserved.
|-
|&lt;tt&gt;incl-types&lt;/tt&gt;
|'''&lt;tt&gt;true&lt;/tt&gt;''',&lt;tt&gt;false&lt;/tt&gt;
|If &lt;tt&gt;true&lt;/tt&gt;, the content of &lt;tt&gt;attribute&lt;/tt&gt; elements is preserved. &lt;tt&gt;ref&lt;/tt&gt; elements within attribute definitions are not resolved.
|-
|&lt;tt&gt;incl-conditions&lt;/tt&gt;
|'''&lt;tt&gt;true&lt;/tt&gt;''',&lt;tt&gt;false&lt;/tt&gt;
|If &lt;tt&gt;true&lt;/tt&gt;, &lt;tt&gt;attribute&lt;/tt&gt; and &lt;tt&gt;element&lt;/tt&gt; elements get a &lt;tt&gt;condition&lt;/tt&gt; attribute that contains all ancestor &lt;tt&gt;choice&lt;/tt&gt;, &lt;tt&gt;optional&lt;/tt&gt;, etc. elements as an XPath expression, up to the next &lt;tt&gt;element&lt;/tt&gt; element. &lt;tt&gt;combine=&quot;interleave&quot;&lt;/tt&gt; attributes that occur at &lt;tt&gt;define&lt;/tt&gt; elements that are resolved are converted into an &lt;tt&gt;interlave&lt;/tt&gt; XPath component. &lt;tt&gt;combine=&quot;interleave&quot;&lt;/tt&gt; attributes are converted into &lt;tt&gt;interleave&lt;/tt&gt;.  
|-
|&lt;tt&gt;incl-elements&lt;/tt&gt;
|&lt;tt&gt;true&lt;/tt&gt;,'''&lt;tt&gt;false&lt;/tt&gt;'''
|If &lt;tt&gt;true&lt;/tt&gt;, information regarding child elements is included..
|}

== create-attribute-xref.xsl  ==

This style sheet creates an attribute cross reference from a flat ODF schema which has been created using '''create_flat_schema.xsl'''. The cross reference is a spreadsheet that list all elements that ODF defines, the attributes that these may have, and their data types.

The input is a flat schema, the output a '''content.xml''' that may be used with an appropriate ODF spreadsheet. An example spreadhseet is included in the '''misc''' folder. It has the name '''odf-attribute-xref.odt'''

The following commands creates the ODF attribute reference:

 cp &lt;odf xslt runner folder&gt;/misc/odf-attribute-xref.odt odf-attribute-xref.odt
 java -jar odfxsltrunner.jar &lt;odf xslt runner folder&gt;/sample_xslt/create_flat_schema.xsl -i &lt;(strict) ODF schema-file&gt; -o flat-odf-schema.rng
 java -jar odfxsltrunner.jar &lt;odf xslt runner folder&gt;/sample_xslt/create-attribute-xref.xsl -i flat-odf-schema.rng -t odf-attribute-xref.odt &quot;incl-conditions=false&quot; &quot;incl-default-values=true&quot; &quot;incl-types=true&quot; &quot;incl-elements=false&quot;
</text>
  <text-as-html>&lt;h1&gt;&lt;a name='ODF_XSLT_Runner_and_ODF_XSLT_Runner_Task_Examples'&gt;&lt;/a&gt; ODF XSLT Runner and ODF XSLT Runner Task Examples &lt;/h1&gt;
&lt;div id='toc' class='toc'&gt;
           &lt;div id='toctitle' class='toc-title'&gt;
             &lt;span&gt;Contents&lt;/span&gt;
           &lt;/div&gt;
           &lt;div id='toccontents' class='toc-contents'&gt;&lt;ul&gt;&lt;li&gt;1 &lt;a href='#ODF_XSLT_Runner_and_ODF_XSLT_Runner_Task_Examples'&gt; ODF XSLT Runner and ODF XSLT Runner Task Examples &lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;1.1 &lt;a href='#create_flat_schema.xsl'&gt; create_flat_schema.xsl  &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;1.2 &lt;a href='#create-attribute-xref.xsl'&gt; create-attribute-xref.xsl  &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;/div&gt;
         &lt;/div&gt;&lt;p&gt;&lt;br /&gt;

&lt;/p&gt;&lt;p&gt;The &lt;b&gt;samle_xslt&lt;/b&gt; folder contained in the &lt;a class='external' href=&quot;http://odftoolkit.org/sources/odf-xslt-Runner-src/show&quot;&gt;source code&lt;/a&gt; of the ODF XSLT Runner project contains several example XSLT style sheets.

&lt;/p&gt;&lt;p&gt;The &lt;b&gt;build_xref.xml&lt;/b&gt; file contained in the  &lt;a href='&lt;?url_for_page ODF XSLT Runner?&gt;' class='internal'&gt;ODF XSLT Runner&lt;/a&gt; project contains several targets that run these style sheets using &lt;b&gt;ODF XSLT Runner&lt;/b&gt;.

&lt;/p&gt;&lt;p&gt;The &lt;b&gt;build_xref.xml&lt;/b&gt; file contained in the  &lt;a href='&lt;?url_for_page ODF XSLT Runner Task?&gt;' class='internal'&gt;ODF XSLT Runner Task&lt;/a&gt; project contains several targets that run these style sheets using &lt;b&gt;ODF XSLT Runner Task&lt;/b&gt;.

&lt;/p&gt;&lt;h2&gt;&lt;a name='create_flat_schema.xsl'&gt;&lt;/a&gt; create_flat_schema.xsl  &lt;/h2&gt;
&lt;p&gt;
This XSLT style sheets converts an ODF schema into a simplified &amp;quot;flat&amp;quot; variant by resolving Relax-NG &lt;tt&gt;ref&lt;/tt&gt; elements and by making several other simplifications. 

&lt;/p&gt;&lt;p&gt;The resulting &amp;quot;flat schema&amp;quot; contains all &lt;tt&gt;element&lt;/tt&gt; elements as children of the &lt;tt&gt;grammar&lt;/tt&gt; element, regardless whether these may occur on top level or not. These element have  &lt;tt&gt;attribute&lt;/tt&gt; child elements for all attributes that may be used with the element, and optionally &lt;tt&gt;element&lt;/tt&gt; elements for all child elements.

&lt;/p&gt;&lt;p&gt;The resulting schema is not equivalent to the source schema, and it must not be used for validating documents. Instead its purpose is to provide a basis for creating cross references regarding the ODF specification.  

&lt;/p&gt;&lt;p&gt;This stylesheet does neither take an ODF document as input nor does it produce one. It therfore can be called by an usual XSLT processor.  It may also be called by odfxsltrunner using the following command line:

&lt;/p&gt;&lt;pre&gt; java -jar odfxsltrunner.jar create_flat_schema.xsl -i &amp;lt;(strict) ODF schema-file&amp;gt; -o &amp;lt;flat ODF schema file&amp;gt;
&lt;/pre&gt;&lt;p&gt;
The following paramters control the conversion:

&lt;/p&gt;&lt;div style=&quot;overflow-x: auto;&quot;&gt;&lt;div style=&quot;margin: 0px 2px 0px 2px;&quot;&gt;
&lt;table - border=&quot;1&quot;&gt;&lt;tr&gt;&lt;th&gt;name
&lt;/th&gt;&lt;th&gt;values
&lt;/th&gt;&lt;th&gt;description
&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;tt&gt;incl-default-values&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/b&gt;,&lt;tt&gt;false&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;If &lt;tt&gt;true&lt;/tt&gt;, default values specified by &lt;tt&gt;a:defaultValue&lt;/tt&gt; attributes are preserved.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;tt&gt;incl-types&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/b&gt;,&lt;tt&gt;false&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;If &lt;tt&gt;true&lt;/tt&gt;, the content of &lt;tt&gt;attribute&lt;/tt&gt; elements is preserved. &lt;tt&gt;ref&lt;/tt&gt; elements within attribute definitions are not resolved.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;tt&gt;incl-conditions&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/b&gt;,&lt;tt&gt;false&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;If &lt;tt&gt;true&lt;/tt&gt;, &lt;tt&gt;attribute&lt;/tt&gt; and &lt;tt&gt;element&lt;/tt&gt; elements get a &lt;tt&gt;condition&lt;/tt&gt; attribute that contains all ancestor &lt;tt&gt;choice&lt;/tt&gt;, &lt;tt&gt;optional&lt;/tt&gt;, etc. elements as an XPath expression, up to the next &lt;tt&gt;element&lt;/tt&gt; element. &lt;tt&gt;combine=&amp;quot;interleave&amp;quot;&lt;/tt&gt; attributes that occur at &lt;tt&gt;define&lt;/tt&gt; elements that are resolved are converted into an &lt;tt&gt;interlave&lt;/tt&gt; XPath component. &lt;tt&gt;combine=&amp;quot;interleave&amp;quot;&lt;/tt&gt; attributes are converted into &lt;tt&gt;interleave&lt;/tt&gt;.  
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;tt&gt;incl-elements&lt;/tt&gt;&lt;/td&gt;&lt;td&gt;&lt;tt&gt;true&lt;/tt&gt;,&lt;b&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;If &lt;tt&gt;true&lt;/tt&gt;, information regarding child elements is included..
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;h2&gt;&lt;a name='create-attribute-xref.xsl'&gt;&lt;/a&gt; create-attribute-xref.xsl  &lt;/h2&gt;
&lt;p&gt;
This style sheet creates an attribute cross reference from a flat ODF schema which has been created using &lt;b&gt;create_flat_schema.xsl&lt;/b&gt;. The cross reference is a spreadsheet that list all elements that ODF defines, the attributes that these may have, and their data types.

&lt;/p&gt;&lt;p&gt;The input is a flat schema, the output a &lt;b&gt;content.xml&lt;/b&gt; that may be used with an appropriate ODF spreadsheet. An example spreadhseet is included in the &lt;b&gt;misc&lt;/b&gt; folder. It has the name &lt;b&gt;odf-attribute-xref.odt&lt;/b&gt;

&lt;/p&gt;&lt;p&gt;The following commands creates the ODF attribute reference:

&lt;/p&gt;&lt;pre&gt; cp &amp;lt;odf xslt runner folder&amp;gt;/misc/odf-attribute-xref.odt odf-attribute-xref.odt
 java -jar odfxsltrunner.jar &amp;lt;odf xslt runner folder&amp;gt;/sample_xslt/create_flat_schema.xsl -i &amp;lt;(strict) ODF schema-file&amp;gt; -o flat-odf-schema.rng
 java -jar odfxsltrunner.jar &amp;lt;odf xslt runner folder&amp;gt;/sample_xslt/create-attribute-xref.xsl -i flat-odf-schema.rng -t odf-attribute-xref.odt &amp;quot;incl-conditions=false&amp;quot; &amp;quot;incl-default-values=true&amp;quot; &amp;quot;incl-types=true&amp;quot; &amp;quot;incl-elements=false&amp;quot;
&lt;/pre&gt;</text-as-html>
  <updated-at type="datetime">2009-02-13T14:34:02Z</updated-at>
  <wiki-id type="integer">51</wiki-id>
</page>
