DITA example

Inside the root documentProcessing element in the documentProcessing.xml file, insert a pathRewriting element if it is not already there.

The example in this task configures two references. After following this two examples, you should be able to configure the other references yourselves. The examples are the following:

  1. All elements that have a href attribute and a format attribute with dita or ditamap as value and a scope attribute with local as value.

  2. A reference to an image.

Example 1

Configure cross references to another DITA document.

Inside the pathRewriting element, create a reference element with the attributes typeName="document" and targetAttribute="href".

The typeName corresponds with the reference types that you have configured in the Fonto Editor.

The targetAttribute corresponds with the attribute in the XML that contains the reference target.

Your pathRewriting configuration should now look like this:

documentProcessing.xml

XML

<documentProcessing xmlns="http://schemas.fontoxml.com/connectors/2.0/documentProcessing.xsd" xmlns:xlink="http://www.w3.org/1999/xlink">
	<pathRewriting>
		<reference typeName="document" targetAttribute="href">
		</reference>
	</pathRewriting>
</documentProcessing>

Configure the allowed DITA format and DITA scope attribute values.

Fonto Connectors has built in DITA support. To constraint a reference configuration on DITA scope and DITA format attributes, use the ditaScopes and ditaFormats elements in the matchingConstraints section.

To configure the DITA format and DITA scope attribute constraints, add the following part in the previously created reference element:

XML

<matchingConstraints>
	<ditaFormats>
		<ditaFormat format="dita"/>
		<ditaFormat format="ditamap"/>
	</ditaFormats>
	<ditaScope scope="local"/>
</matchingConstraints>

Your documentProcessing.xml file should now look like this:

documentProcessing.xml

XML

<documentProcessing xmlns="http://schemas.fontoxml.com/connectors/2.0/documentProcessing.xsd">
	<pathRewriting>
		<reference typeName="document" targetAttribute="href">
			<matchingConstraints>
				<ditaFormats>
					<ditaFormat format="dita"/>
					<ditaFormat format="ditamap"/>
				</ditaFormats>
				<ditaScope scope="local"/>
			</matchingConstraints>
		</reference>
	</pathRewriting>
</documentProcessing>

Example 2

Configure image references.

Inside the pathRewriting element, create a reference element with the attributes typeName="image" and targetAttribute="href".

You must create this reference element below the reference element that you configured in example 1. The reference elements in the pathRewriting elements are a fallback list, the reference will be resolved via the first reference element it matches.

Your pathRewriting configuration should now look like this:

XML

<documentProcessing xmlns="http://schemas.fontoxml.com/connectors/2.0/documentProcessing.xsd" xmlns:xlink="http://www.w3.org/1999/xlink">
	<pathRewriting>
		<reference typeName="document" targetAttribute="href">
			<!-- Configuration from example 1 -->
		</reference>
		<reference typeName="image" targetAttribute="href">
		</reference>
	</pathRewriting>
</documentProcessing>

Configure the allowed dita format attributes.

This configuration now selects all href attributes, this is not the correct behavior, because web references are now also marked as an image reference. To restrict this reference configuration to only be matched on images, add the following DITA format attribute restriction in the just created reference element:

XML

<matchingConstraints>
	<ditaFormats>
		<ditaFormat format="bmp"/>
		<ditaFormat format="gif"/>
		<ditaFormat format="ico"/>
		<ditaFormat format="jpeg"/>
		<ditaFormat format="jpg"/>
		<ditaFormat format="png"/>
		<ditaFormat format="svg"/>
	</ditaFormats>
</matchingConstraints>

Your documentProcessing.xml should now look like this:

documentProcessing.xml

XML

<documentProcessing xmlns="http://schemas.fontoxml.com/connectors/2.0/documentProcessing.xsd" xmlns:xlink="http://www.w3.org/1999/xlink">
	<pathRewriting>
		<reference typeName="document" targetAttribute="href">
			<!-- Configuration from example 1 -->
		</reference>
		<reference typeName="image" targetAttribute="href">
			<matchingConstraints>
				<ditaFormats>
					<ditaFormat format="bmp"/>
					<ditaFormat format="gif"/>
					<ditaFormat format="ico"/>
					<ditaFormat format="jpeg"/>
					<ditaFormat format="jpg"/>
					<ditaFormat format="png"/>
					<ditaFormat format="svg"/>
				</ditaFormats>
			</matchingConstraints>
		</reference>
	</pathRewriting>
</documentProcessing>

You should now have enough knowledge to work with the ditaScope and ditaFormat restrictions. This allows you to complete the path rewriting configuration for DITA. For more generic documentation on path rewriting, please review the JATS example, which introduces the more common path rewriting options.