Modify

Ticket #68 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

Xinclude filter

Reported by: bkarwin Owned by: hans
Priority: minor Milestone: 2.3.0
Component: phing-tasks-ext Version: 2.2.0
Keywords: xml filter xinclude Cc:

Description

I wanted to use Phing to process some Docbook XML files. One common way of including chapter files in a Docbook book is to use parameter entities. Unfortunately, I found that PHP's XML classes don't support parameter entities (this is a PHP issue, independent of Phing).

So I thought I could use the more modern and flexible Xinclude syntax to include chapter files in my Docbook book, instead of using parameter entities.

Phing doesn't support Xinclude, but PHP's DOM XML class does. So I wrote a filter class to process files using DomDocument::xinclude(). It's very simple. I now have Docbook building from a Phing script.

The implementation is one chained filter class that belongs in the filters subdirectory. Also we need to edit the types/FilterChain.php to recognize the new filter class.

Here's an example of using the xinclude filter, chaining with xsltfilter to render Docbook:

    <echo msg="Rendering Docbook manual using Xinclude and XSLT..." />
    <copy todir="${manual.dest.dir}">
      <filterchain>
        <xincludefilter basedir="${manual.src.dir}" />
        <xsltfilter style="${manual.src.dir}/html.xsl">
          <param name="base.dir" expression="${manual.dest.dir}/" />
        </xsltfilter>
      </filterchain>
      <fileset dir="${manual.src.dir}">
        <include name="manual.xml" />
      </fileset>
    </copy>

The xinclude filter has an argument called basedir. The filter actually changes working directory temporarily to that basedir, so that relative paths referenced in the xinclude tags will work.

Attachments

XincludeFilter.php Download (3.9 KB) - added by bkarwin 5 years ago.
Xinclude filter class.

Change History

Changed 5 years ago by bkarwin

Xinclude filter class.

comment:1 Changed 5 years ago by hans

  • Owner set to hans
  • Status changed from new to assigned
  • Component set to phing-tasks-ext
  • Milestone changed from 2.2.1 to 2.3.0

comment:2 Changed 5 years ago by hans

  • Status changed from assigned to closed
  • Resolution set to fixed

Hmmm -- this has already been committed, I guess. Not sure why it's still open :)

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.