Transformation scenario: turn off XInclude expansion

Post here questions and problems related to oXygen frameworks/document types.
Krille
Posts: 26
Joined: Thu Nov 12, 2020 12:24 pm

Transformation scenario: turn off XInclude expansion

Post by Krille »

Hi!

Is there a way to turn of the expansion of XIncludes for a single transformation scenario automatically?

There was a discussion, where it was suggested to turn of the expansion in Options > Preferences > XML > ...
other-issues/topic10319.html
But this turns on/off XInclude expansion for the parser everywhere. This is much too complicated for our users and might lead to data corruption, if not handled with care.

I'd like offer our users a scenario, where XIncludes aren't expanded, and they needn't care about switching on/off at all.

If it isn't possible to turn off the expansion in a normal XSLT transformation scenario (because it uses oXygen's core XML parser): Would it be possible with an ANT based scenario?

Kind regards,
Christian
Radu
Posts: 8010
Joined: Fri Jul 09, 2004 5:18 pm

Re: Transformation scenario: turn off XInclude expansion

Post by Radu »

Hi Christian,

I'm afraid there is no such possibility with our XSLT based transformation scenarios.
With an ANT xslt task indeed you can control things better:
https://ant.apache.org/manual/Tasks/style.html
probably by forcing a non xi:Include aware parsing configuration:

Code: Select all

<xslt ...>
    <sysproperty key="org.apache.xerces.xni.parser.XMLParserConfiguration"
                 value="org.apache.xerces.parsers.XML11Configuration"/>
<xslt>
but this may need to be tested.
We have a pre-configured "Ant (with Saxon-HE XSLT support)" transformation scenario which should be accessible when editing ANT build files.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Krille
Posts: 26
Joined: Thu Nov 12, 2020 12:24 pm

Re: Transformation scenario: turn off XInclude expansion

Post by Krille »

Hi Radu!

That works great! If someone want's to do similar things, here's my ANT file:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!-- ANT build script

USAGE (commandline):

ant -buildfile THISFILE \
	-Dsaxon.jar=~/.m2/repository/net/sf/saxon/Saxon-HE/10.2/Saxon-HE-10.2.jar \
	-DinputFile=SOURCE \
	-DoutputFile=DEST \
	-Dreading=lemma \
	extract-reading

-->
<project basedir="." name="ALEA">

	<!-- oxygenlib, defaults to ant lib -->
	<property name="oxygenlib" value="..."/>

	<!-- define the the saxon transformer or place it in the ant lib directory -->
	<property name="saxon.jar" value="${oxygenlib}/saxon9he.jar"/>

	<!-- Path to TEI XML file. -->
	<property name="inputFile" value=""/>

	<!-- Path where the output file will be saved. -->
	<property name="outputFile" value=""/>

	<!-- suffix of TEI documents -->
	<property name="teiSuffix">.tei.xml</property>

	<!-- author name -->
	<property name="authorname" value="${user.name}"/>

	<!-- directories -->
	<dirname property="outputDir" file="${outputFile}"/>
	<dirname property="inputDir" file="${inputFile}"/>

	<!-- modfiy basedir, if necessary: -Dbasedir=... -->
	<echo> basedir: ${basedir}</echo>

	<echo> using Saxon: ${saxon.jar}</echo>

	<!-- extract reading -->

	<property name="reading" value="lemma"/>
	<property name="recension" value=""/>

	<target name="extract-reading">
		<!-- Task for extracting a reading in order to start encoding an other recension based on it.
			This is done from ANT in order to not expand XIncludes. -->
		<xslt style="xsl/reading.xsl" in="${inputFile}" out="${outputFile}">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
			<classpath location="${saxon.jar}"/>
			<sysproperty key="org.apache.xerces.xni.parser.XMLParserConfiguration"
				value="org.apache.xerces.parsers.XML11Configuration"/>
			<param name="reading" expression="${reading}" type="STRING"/>
			<param name="pdu" expression="${basedir}" type="STRING"/>
			<param name="note-references" expression="true" type="BOOLEAN"/>
			<param name="authorname" expression="${authorname}" type="STRING"/>
		</xslt>
		<echo>Extracted text stored in ${outputFile}</echo>
	</target>
	
	<!-- ... other tasks ... -->

</project>
Kind regards,
Christian
Radu
Posts: 8010
Joined: Fri Jul 09, 2004 5:18 pm

Re: Transformation scenario: turn off XInclude expansion

Post by Radu »

Hi Christian,

Thanks for taking the time to post the entire solution.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply