-
Notifications
You must be signed in to change notification settings - Fork 0
ant
Apache Ant's XSLT target can run XSL transformations from 1.0 to 3.0 and above, we only have to provide it an according XSLT processor like Saxon HE.
Generally, one would apply the extract-collection.xsl XSL
transformation from xtriples-micro to a set of XTriples
configuration files places in a special folder, e.g.,
resources/graph/. One would make this folder configurable by setting
it in a property
called ${xtriples-config}; and one would make the path to the
XTriples installation configurable
through the property ${xtriples}:
<build basedir=".">
<property name="edition" value=""/>
<!-- path to the edition, relative from this build file -->
<property name="edition.rel" value=".."/>
<!-- absolute path to the edition, calculated from edition.rel -->
<property name="edition" location="${edition.rel}"/>
<!-- ... -->
<property name="xtriples" value="${basedir}/target/dependencies/xtriples"/>
<property name="xtriples-config" value="${basedir}/graph"/>
<property name="dist-graph" value="${edition}/dist"/>
<!-- ... -->
<!-- setting the classpath -->
<property name="oxygenlib" value="${basedir}/target/lib"/>
<path id="project.class.path">
<fileset dir="${oxygenlib}">
<include name="*.jar"/>
</fileset>
</path>
<!-- ... -->
<target name="xtriples">
<xslt classpathref="project.class.path"
style="${xtriples}/xsl/extract-collection.xsl"
basedir="${xtriples-config}"
includes="*.xml"
destdir="${dist-graph}">
<factory name="net.sf.saxon.TransformerFactoryImpl">
<attribute name="http://saxon.sf.net/feature/xinclude-aware" value="on"/>
</factory>
<mapper type="glob" from="*.xml" to="*.n3"/>
</xslt>
</target>
<!-- ... -->
</build><mapper> is present, to set the extension of the output files to
.n3. The <attribute> make the XML parse XInclude aware, which may
be important for your TEI-XML source documents.
Which TEI-XML source files are RDF triples are extracted from is
determined by the <collection> part of the XTriples configuration
files.
The stuff for setting the classpath assumes a similar directory
layout, where all
technical stuff like this Ant build file is in the resources (or
tooling) folder and the required Java libraries like Saxon-HE and
its dependencies are in resources/target/lib. It's a typical
Tooling layout.
Ant can also be used to merge or concatenate all n3 files into one
file, knowledge-graph.n3:
<target name="knowledge-graph.n3" depends="xtriples,alea.n3">
<concat destfile="${dist-graph}/knowledge-graph.n3">
<fileset dir="${dist-graph}" includes="*.n3" excludes="knowledge-graph.n3"/>
</concat>
</target>To get another RDF serialization, install Jena RIOT with the Tooling environment and apply it from Ant:
<target name="knowledge-graph.json" depends="knowledge-graph.n3">
<java classpathref="project.class.path" classname="jena.riot"
output="${dist-graph}/knowledge-graph.json" logerror="true">
<arg value="--out=JSONLD"/>
<arg value="${dist-graph}/knowledge-graph.n3"/>
</java>
</target>Maybe your edition also contains other RDF statements, e.g., an
ontology written in RDF/Turtle. You can convert them to n3 before
merging:
<target name="alea.n3">
<java classpathref="project.class.path" classname="jena.riot" output="${dist-graph}/alea.n3"
logerror="true">
<arg value="--out=ntriples"/>
<arg value="${edition}/alea.ttl"/>
</java>
</target>To allways run all these targets in the right order, use a meta target:
<target name="knowledge-graph"
description="Extracts a RDF knowledge graph from the TEI-XML edition">
<antcall target="xtriples"/>
<antcall target="alea.n3"/>
<antcall target="knowledge-graph.n3"/>
<antcall target="knowledge-graph.json"/>
</target>