Publishing

Publishing PageSeeder data to print, the Web or both

Task diff

This task was introduced in PageSeeder version 5.9605.

When the Task export is used with the attribute compareto="[version]" it will generate PSML with a <compare> element for each fragment that has been edited since the version specified. The <compare> element has a <content> element which contains the content of the fragment at the time of the version.

This task will add a <diff> element under each <compare> element which is the DiffX  comparison between the version being exported and the compareto version. For example:

<diff>
  <fragment xmlns:dfx="http://www.topologi.com/2005/Diff-X"
      xmlns:del="http://www.topologi.com/2005/Diff-X/Delete"
      xmlns:ins="http://www.topologi.com/2005/Diff-X/Insert" id="2">
    <para>The <dfx:del>quick</dfx:del><dfx:ins>slow</dfx:ins></para>
    <para indent="1" ins:indent="true">brown</para>
    <para del:indent="1">fox</para>
    <para dfx:insert="true"><dfx:ins>jumps</dfx:ins></para>
  </fragment>
</diff>

Note

  • This task only works on PSML with level="portable".
  • Only files with <compare> elements will be output to the destination folder.
  • If the diff fails for some reason then no <diff> element will be added for that fragment.

Definition

Minimal definition:

<ps:diff 
             src="[source]"
            dest="[destination]"/>

 Full definition:

<ps:diff
              src="[source]"
             dest="[destination]"
        maxevents="[maximum diff events]"
      granularity="[character|word|text]"
       whitespace="[compare|preserve|ignore]">

  <files>
    <include name="[name]" />
    <exclude name="[name]" />
  </files>

</ps:diff>

Attributes

AttributeDescriptionRequiredDefault

src

The source folder on the file system of the universal portable format input. For example:

c:\working\download

Yes

dest

The destination folder on the file system for the output files. For example:

c:\working\diff

Yes

maxevents

The maximum number of diff events allowed (see below).

No

"4000000"

granularity

Defines the granularity of the text compare used by DiffX. Allowed values are:

  • character: compare individual characters e.g. fox jump<ins>ing</ins>;
  • word: compare individual words e.g. fox <del>jump</del><ins>jumping</ins>;
  • text: compare all text between elements e.g. <del>fox jump</del><ins>fox jumping</ins>.

No

"word"

whitespace

Defines how the white spaces should be processed by Diff-X. Allowed values are:

  • compare: compare white space;
  • preserve: preserve but don't compare white space;
  • ignore: don't preserve or compare white space.

No

"preserve"

Note

Diff events are the number of elements/attributes/text in each fragment multiplied by each other. When maxevents is reached the diff will set the coarsest granularity (text) and try again. If events is still larger than maxevents the <diff> element will not be generated. For reasonable performance a maximum of 4,000,000 is recommended. 

Elements

Element <files>

Used to only diff certain files in the src folder.

This element may contain multiple nested <include name="" /> or <exclude name="" /> elements as defined below.

Element <inlcude>

A pattern matching documents/folders to include. If not present, then all documents/folders are included.

AttributeDescriptionRequired

name

The pattern with format is similar to the file selection in other Ant tasks. Examples:

*.psml
archive
folder1/*.psml
**/*.psml

Yes

 

Element <exclude>

A pattern matching documents/folders to exclude. If not present, then no documents/folders are excluded.

AttributeDescriptionRequired

name

The pattern with format is similar to the file selection in other Ant tasks. Examples:

_local/**
_external/**

Yes

Examples

Diff and prepare for processing

The example below adds diff elements to exported documents and then copies them back to the original folder so they can be processed.

<ps:diff src="c:\working\export" dest="c:\working\diff"/>

<copy todir="c:\working\export" overwrite="true">
  <fileset dir="c:\working\diff" />
</copy>

Only diff certain folders

The example below only diffs PSML files under the top level articles folder.

<ps:diff src="c:\working\export" dest="c:\working\diff">
  <files>
    <include name="articles/**" />
  </files>
</ps:diff>

Created on , last edited on