# Creating XML Filters

/text/shared/guide/xsltfilter_create.xhp
testing XML filters
XML filters;creating/testing
mw moved 2 index entries from xsltfilter.xhp, then changed "XML filters;"
Creating XML Filters
Creating an XML Filter for %PRODUCTNAME
When you create an XML filter for %PRODUCTNAME, you need to design an XSLT stylesheet that can convert to and from the OpenDocument XML file format.
For more information about the OpenDocument XML format, go to http://xml.openoffice.org/.
If you want, you can include a template with your filter to apply %PRODUCTNAME styles to an XML document that you import.
You can also include the Document Type Definition (DTD) for the external XML format so you can validate the XML format, for example, when you test the filter.
To Create an XML Filter
- Create an XSLT transformation stylesheet that maps the elements of the external XML format to the elements of the OpenDocument XML file format and back again.
- Create a template that assigns %PRODUCTNAME styles to elements in the external XML format when you import a file in this format into %PRODUCTNAME.
- In %PRODUCTNAME Writer, create a text document, and choose Tools - XML Filter Settings.
- Click New.
- In the XML Filter dialog, click the General tab, and define the properties of the filter.
- In the Filter Name box, enter a name for the XML filter.
  This name is displayed in the XML Filter Settings dialog.
- In the Application box, select the %PRODUCTNAME application that the filter is for.
- In the Name of File Type box, enter the file type that the filter is for.
  This name is displayed in the list of file types in the Open, Export, and Save As dialogs.
- In the File extension box, enter the extension for the exported file.
  To differentiate the file from other XML files, enter an extension other than *.xml.
- On the Transformation tab page, define the transformation properties for the filter.
- (Optional) In the DocType box, enter the document type identifier for the external file format.
  This identifier is used to detect the file type on import.
- (Optional) In the DTD box, enter the path and file name of the DTD for the external file format.
  This DTD is used to validate the files on export.
- In the XSLT for export box, enter the path and file name of the XSLT stylesheet that defines the transformation from OpenDocument format to the external format.
- In the XSLT for import box, enter the path and file name to the XSLT stylesheet that defines the transformation from the external format to OpenDocument format.
- (Optional) In the Template for import box, enter the path and name of the template that defines the %PRODUCTNAME styles that are used in the imported file.
  The files that are specified on the Transformation tab page are copied to the local %PRODUCTNAME users directory.
- Click OK.
To Test an XML Filter
You can perform basic tests on a custom XML filter in %PRODUCTNAME.
The document is not altered by these tests.
- Create or open a text document.
- Choose Tools - XML Filter Settings.
- In the list of filters, select the filter that you want to test, and click Test XSLTs.
- To test an Export Filter, do one of the following in the Export area of the dialog:
- Click Browse, select the %PRODUCTNAME document that you want to test, and click Open.
- To test the current document, click Current Document.
- To test an Import Filter, click Browse in the Import area of the dialog, select a document, and click Open.
- To validate the transformed file against the specified DTD, click Validate.
About XML Filters
Distributing XML filters