TEIC / Stylesheets

TEI XSL Stylesheets
231 stars 124 forks source link

add `@classpathref` to `common/teianttasks.xml` #544

Closed bwbohl closed 1 year ago

bwbohl commented 2 years ago

I'm using the TEI Stylesheets as submodule in some non TEI schema development repositories for building the schemata from my ODD definitions. The setup has a project specific ant build.xml that calls the dist target relaxng/build-to.xml. As my main repo has its own lib folder with anything needed for building I would like to just submit my classpath-ref to the TEI-anttasks instead of setting up the environment at submodule level. This fails though, because e.g. the macrodefcalled buildgeneric relies on saxon being on the JAVA class path. As my repositories are designed to be self sufficient (pulling all build required dependencies, instead of relying on them being on the host JAVA class path) this fails. A easy fix could be provided by adding a @classpathref to the ant:xslt calls defined in teianttasks.xml that references the ant:path defined in:

https://github.com/TEIC/Stylesheets/blob/1616df8470d0805356d6dc2b4926c81bec37a554/common/teianttasks.xml#L59-L61

e.g.:

  <macrodef name="buildgeneric">
    <attribute name="in"/>
    <attribute name="out"/>
    <attribute name="xsl"/>
    <attribute name="type"/>
    <sequential>
      <echo level="info">XSLT generate @{type} files</echo>
      <xslt force="yes" style="@{xsl}" in="@{in}" out="@{out}" classpathref="classpath">
        <xmlcatalog>
          <catalogpath>
            <pathelement location="$catalogfile"/>
          </catalogpath>
        </xmlcatalog>
        <factory name="net.sf.saxon.TransformerFactoryImpl">
          <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
        </factory>
      <!-- [ omitted for illustrative purposes] -->
      </xslt>
    </sequential>
  </macrodef>

This would allow me to submit my project-classpath as ref when calling the build, e.g.:

<ant dir="submodules/Stylesheets/relaxng/" antfile="build-to.xml" target="dist" usenativebasedir="true">
            <property name="inputFile" value="${basedir}/${customization.path}"/>
            <property name="outputFile" value="${basedir}/schemata/${odd.basename}.rng"/>
            <property name="defaultSource" value="${basedir}/${dist.dir}/kb_canonicalized.xml"/>
            <property name="verbose">true</property>
            <reference refid="kb.classpath" torefid="classpath"/>
        </ant>

If you think this would be a valuable addition to the TEI Stylesheets, I'd be happy to file a pull request.

martindholmes commented 2 years ago

@HelenaSabel, @sydb and I tested this morning, and we would prefer to add the attribute to all 14 calls to xslt in the teianttasks.xml file, which we have done in branch issue-544-classpathref. This passes all Test and Test2 processes. @bwbohl Could you test this branch and see if it does what you need? If it works for you, we'll create a pull request.

bwbohl commented 2 years ago

will do

bwbohl commented 2 years ago

sorry for coming back to this so late… works here, many thanks!

bwbohl commented 2 years ago

Is there anything I can do to get this into the next release ;-) Should I open a PR?

HelenaSabel commented 1 year ago

Fixed via https://github.com/TEIC/Stylesheets/pull/550