<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->

<meta>
  <topic id="textsharedguidexsltfilter_createxhp" indexer="include" status="PUBLISH">
    <title xml-lang="en-US" id="tit">Creating XML Filters </title>
    <filename>/text/shared/guide/xsltfilter_create.xhp</filename>
  </topic>
</meta>
<body>
<bookmark xml-lang="en-US" branch="index" id="bm_id7007583">
<bookmark_value>testing XML filters</bookmark_value>
<bookmark_value>XML filters; creating/testing</bookmark_value>
</bookmark>
  <comment>mw moved 2 index entries from  xsltfilter.xhp, then changed "XML filters;"</comment>
<paragraph xml-lang="en-US" id="hd_id1413922" role="heading" level="1"><variable id="xsltfilter"><link href="text/shared/guide/xsltfilter_create.xhp">Creating XML Filters</link> </variable></paragraph>
<paragraph xml-lang="en-US" id="par_idN1053D" role="heading" level="2">Creating an XML Filter for %PRODUCTNAME</paragraph>
  <paragraph xml-lang="en-US" id="par_idN109A9" role="paragraph">When you create an XML filter for %PRODUCTNAME, you need to design an <emph>XSLT stylesheet</emph> that can convert to and from the OpenDocument XML file format.</paragraph>
  <paragraph xml-lang="en-US" id="par_idN109B0" role="tip">For more information about the OpenDocument XML format, go to <link href="https://www.openoffice.org/xml/">https://www.openoffice.org/xml/</link>.</paragraph>
  <paragraph xml-lang="en-US" id="par_idN109C5" role="paragraph">If you want, you can include a <emph>template</emph> with your filter to apply %PRODUCTNAME styles to an XML document that you import.</paragraph>
<paragraph xml-lang="en-US" id="par_idN10531" role="heading" level="2">To Create an XML Filter</paragraph>
<list type="ordered">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN109E0" role="paragraph">Create an XSLT transformation <emph>stylesheet</emph> that maps the elements of the external XML format to the elements of the OpenDocument XML file format and back again.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN109E8" role="paragraph">Create a template that assigns %PRODUCTNAME styles to elements in the external XML format when you import a file in this format into %PRODUCTNAME.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN109EC" role="paragraph">In %PRODUCTNAME Writer, create a text document, and choose <item type="menuitem">Tools - XML Filter Settings</item>.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN109F4" role="paragraph">Click <emph>New</emph>.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN109FC" role="paragraph">In the <emph>XML Filter</emph> dialog, click the <emph>General</emph> tab, and define the properties of the filter.</paragraph>
  </listitem>
</list>
<list type="unordered">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A03" role="paragraph">In the <emph>Filter Name</emph> box, enter a name for the XML filter.</paragraph>
    <paragraph xml-lang="en-US" id="par_idN10CA1" role="paragraph">This name is displayed in the <emph>XML Filter Settings</emph> dialog.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A09" role="paragraph">In the <emph>Application</emph> box, select the %PRODUCTNAME application that the filter is for.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A0F" role="paragraph">In the <emph>Name of File Type</emph> box, enter the file type that the filter is for.</paragraph>
    <paragraph xml-lang="en-US" id="par_idN10CC6" role="paragraph">This name is displayed in the list of file types in the <emph>Open</emph>, <emph>Export</emph>, and <emph>Save As</emph> dialogs.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A15" role="paragraph">In the <emph>File extension</emph> box, enter the extension for the exported file.</paragraph>
    <paragraph xml-lang="en-US" id="par_idN10A1B" role="note">To differentiate the file from other XML files, enter an extension other than *.xml.</paragraph>
  </listitem>
</list>
<list type="ordered" startwith="6">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A1F" role="paragraph">On the <emph>Transformation</emph> tab page, define the transformation properties for the filter.</paragraph>
  </listitem>
</list>
<list type="unordered">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A26" role="paragraph">(Optional) In the <emph>DocType</emph> box, enter the document type identifier for the external file format.</paragraph>
    <paragraph xml-lang="en-US" id="par_idN10D0E" role="paragraph">This identifier is used to detect the file type on import.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A32" role="paragraph">In the <emph>XSLT for export</emph> box, enter the path and file name of the XSLT stylesheet that defines the transformation from OpenDocument format to the external format.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A38" role="paragraph">In the <emph>XSLT for import</emph> box, enter the path and file name to the XSLT stylesheet that defines the transformation from the external format to OpenDocument format.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A3E" role="paragraph">(Optional) In the <emph>Template for import</emph> box, enter the path and name of the template that defines the %PRODUCTNAME styles that are used in the imported file.</paragraph>
    <paragraph xml-lang="en-US" id="par_idN10A44" role="note">The files that are specified on the <emph>Transformation</emph> tab page are copied to the local %PRODUCTNAME users directory.</paragraph>
  </listitem>
</list>
<list type="ordered" startwith="7">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A4C" role="paragraph">Click <emph>OK</emph>.</paragraph>
  </listitem>
</list>
<paragraph xml-lang="en-US" id="par_idN10A56" role="heading" level="2">To Test an XML Filter</paragraph>
  <paragraph xml-lang="en-US" id="par_idN10A5A" role="paragraph">You can perform basic tests on a custom XML filter in %PRODUCTNAME.</paragraph>
  <paragraph xml-lang="en-US" id="par_idN10A91" role="note">The document is not altered by these tests. </paragraph>
<list type="ordered">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A60" role="paragraph">Create or open a text document.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A67" role="paragraph">Choose <item type="menuitem">Tools - XML Filter Settings</item>.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A6F" role="paragraph">In the list of filters, select the filter that you want to test, and click <emph>Test XSLTs</emph>.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A82" role="paragraph">To test an <emph>Export</emph> filter, do one of the following in the <emph>Export</emph> area of the dialog:</paragraph>
  </listitem>
</list>
<list type="unordered">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10DEB" role="paragraph">Click <emph>Browse</emph>, select the %PRODUCTNAME document that you want to test, and click <emph>Open</emph>.</paragraph>
  </listitem>
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10DF7" role="paragraph">To test the current document, click <emph>Current Document</emph>.</paragraph>
  </listitem>
</list>
<list type="ordered" startwith="5">
  <listitem>
    <paragraph xml-lang="en-US" id="par_idN10A99" role="paragraph">To test an <emph>Import</emph> filter, click <emph>Browse</emph> in the <emph>Import</emph> area of the dialog, select a document, and click <emph>Open</emph>.</paragraph>
  </listitem>
</list>
<section id="relatedtopics">
   <paragraph xml-lang="en-US" id="par_id8579668" role="paragraph"><link href="text/shared/guide/xsltfilter.xhp">About XML Filters</link></paragraph>
   <paragraph xml-lang="en-US" id="par_id5569017" role="paragraph"><link href="text/shared/guide/xsltfilter_distribute.xhp">Distributing XML filters</link></paragraph>
</section>
</body>
</helpdocument>
