---
title: "PSML Ant scripts"
source: https://dev.pageseeder.com/guide/configuration/psml/psml_ant_scripts.html
description: "PSML Ant scripts on the Publish Engine enable administrators to import, export, publish, and process PSML documents. These XML-based scripts follow specific path conventions and utilize PageSeeder Ant tasks, with automatic working folder management and support for user input parameters."
last_updated: 2026-09-08T13:59:56+10:00
tokens: ~1468
---

# PSML Ant scripts

The `build.xml` Ant script files on the Publish Engine are used to import, export, publish and process PSML documents.

These files can be accessed by Administrators under the *Administration menu* \> **\[project\]** \> **Template** \> **Publish scripts**.

> **Note:** Before scripts can be created, they must be configured using the **Configure** links on the Publish scripts page, see the [\<publishing\>](psml_document_config/document_publishing.md) element.

The Publish scripts page creates scripts with the following path:

`[project template]/[source type]/[source extension/][action type]/build.xml`

or for scripts specific to a PSML document type:

`[project template]/psml/[document type]/[action type]/build.xml`

or for scripts specific to a URL type:

`[project template]/url/[URL type]/[action type]/build.xml`

where `project template` must be the same one that the `publish-config.xml`, `document-config.xml` or `url-config.xml` files are under. *URL scripts can only be defined under the [global template](../../../reference/glossary/global_template.md).*

> **Note:** For `<source type="publication">` the `[source type]` in the path is `document` because these are document scripts run on the publication root document.

## Examples

```text

myproject/document/psml/export/build.xml
myproject/document/docx/upload/build.xml
myproject/batch/process/build.xml
myproject/folder/publish/build.xml
myproject/group/export/build.xml
myproject/psml/mytype/publish/build.xml
myproject/url/mytype/process/build.xml
```

### Details

PSML Ant scripts have the following characteristics:

1. They do not need to clear the working folder at the start as is it is cleared automatically before the script is run.
2. They do not need to clear the working folder after running as it is cleared automatically after 72 hours. Also any files in the output folder `${ps.config.default.web.root}/session` are cleared after 12 hours.
3. They can access user input  parameters using `${ps``.param.[name]}`.
4. They should reference PageSeeder properties using `${ps``.config.default.*}`.
5. They should only use non-deprectaed PageSeeder Ant tasks (i.e. not prefixed by `ps-`) and the only configuration required is `<project ... xmlns:ps="antlib:com.pageseeder.publishapi.ant">` :


  1. [Task config](../../publishing/ant_api/tasks/task_config.md)
  2. [Task export](../../publishing/ant_api/tasks/task_export.md)
  3. [Task process](../../publishing/ant_api/tasks/task_process.md)
6. They might also use the following Ant extensions which are now included in the Publish Engine lib so only require the following configuration `<project ... xmlns:psd="antlib:org.pageseeder.docx.ant" xmlns:psp="antlib:org.pageseeder.pdf.ant">` :


  1. [ps-ant-docx](../../publishing/ant_api/extensions/task_export-docx.md)
  2. [ps-ant-pdf](../../publishing/ant_api/extensions/task_export-pdf.md)
7. They might use [AntContrib](https://ant-contrib.sourceforge.net/) tasks by adding the following under `<project>`:  
`<taskdef resource="net/sf/antcontrib/antlib.xml"/>`

> **Warning:** There is a memory leak in the ANT `<xslt>` task when transforming many files in the same call, so to avoid an “out of memory” error. As of Pageseeder v5.9903 use the [Task transform](../../publishing/ant_api/tasks/task_transform.md) instead, otherwise use the ANT `<java>` task as shown below. ```xml <xslt basedir="${source-folder}" destdir="${dest-folder}" style="mytransform.xsl" extension=".xml"> <param name="myparam" expression="${my-value}"/> </xslt> ``` Should be changed to the following (however, note that this WILL NOT process sub-folders): ```xml <java classname="net.sf.saxon.Transform"> <arg value="-s:${source-folder}"/> <arg value="-o:${dest-folder}"/> <arg value="-xsl:${basedir}/mytransform.xsl"/> <arg value="myparam=${my-value}"/> </java> ``` If the source files were `.psml`, then they become `.psml.xml`, so you might also require a `<move>` task to rename them to just `.xml` after the transform as shown below. ```xml <move todir="${dest-folder}"> <fileset dir="${dest-folder}"/> <mapper type="glob" from="*.psml.xml" to="*.xml"/> </move> ```

 

### Example

The following example exports a PSML document to PDF format.

```xml
<project name="document-psml-export" 
         xmlns:ps="antlib:com.pageseeder.publishapi.ant"
         xmlns:psp="antlib:org.pageseeder.pdf.ant">
  <target name="create-consolidated-pdf"
          description="Create PDF Document">    
    <ps:config />   
    <property name="download" 
              value="${ps.config.default.working}/download" />
    <property name="process" 
              value="${ps.config.default.working}/process" />
    <property  name="temp" 
               value="${ps.config.default.working}/temp" />
    <mkdir  dir="${download}"/>
    <mkdir  dir="${process}"/>
    <mkdir  dir="${temp}"/>
    <ps:progress percent="1" message="Downloading documents" />
    <ps:export src="${ps.config.default.uri.path}"
               dest="${download}" 
               xrefdepth="${ps.param.depth}">
      <xrefs types="embed,transclude"/>
    </ps:export>
    <ps:progress percent="50" message="Processing documents"/>
    <ps:process src="${download}"
                dest="${process}" 
                generatetoc="${ps.param.toc}">
      <xrefs types="embed,transclude">
        <include name="${ps.config.default.uri.filename.no.ext}.psml" />
      </xrefs>
    </ps:process>
    <ps:progress percent="70" message="Creating PDF" />   
    <psp:export-pdf
     src="${process}/${ps.config.default.uri.filename.no.ext}.psml"
     dest="${ps.config.default.working}/${ps.config.default.uri.filename.no.ext}.pdf"
     working="${temp}"/>
    <ps:progress percent="90" result="window"
     resultfile="${ps.config.default.working}/${ps.config.default.uri.filename.no.ext}.pdf" />
  </target>
</project>
```

