I am using Docbook 1.78 and xsltproc (libxslt 1.1.26 with libxml 2.7.8) in command line to generate a fo-file from an XML file. My aim is to generate a PDF using Apache formatted output processor (fop; version 1.1). My XML-Input file:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE book SYSTEM "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<book lang="de" id="MyBook">
<chapter id="Introduction">
<title>Introduction</title>
<section id="sec_intro_1">
<title>Test</title>
<para>para1_sec_intro_1 (see also glossary: <xref linkend="gloss_etm-datei"/>).</para>
<para>para2_sec_intro_1</para>
</section>
<section id="sec_intro_2">
<title>Another Test</title>
<para>para1_sec_intro_2 (glossary: <xref linkend="gloss_etm-datei"/>).</para>
<para>para2_sec_intro2</para>
</section>
</chapter>
<xi:include href="glossar_test.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
</book>
If I run the following command
xsltproc -o ./test.fo --xinclude --stringparam paper.type A4 --stringparam fop1.extensions 1 ./docbook/fo/docbook.xsl ./test.xml 2> fo_out.txt
The fo-file is generated but it contains fo:wrapper elements with IDs which are not unique. This is the generated fo-file:
...
(see also glossary: <fo:basic-link internal-destination="gloss_etm-datei"><fo:inline>
<fo:wrapper id="idp8751564240"><!--ETM-Datei--></fo:wrapper>
<fo:inline font-weight="bold">ETM-Datei</fo:inline>
</fo:inline></fo:basic-link>)
....
(glossary: <fo:basic-link internal-destination="gloss_etm-datei"><fo:inline>
<fo:wrapper id="idp8751564240"><!--ETM-Datei--></fo:wrapper>
<fo:inline font-weight="bold">ETM-Datei</fo:inline>
</fo:inline></fo:basic-link>).
...
Now, if I try to generate a pdf file from that fo-file, fop throws an Exception:
SEVERE: Exception
org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:303)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
at org.apache.fop.cli.Main.startFOP(Main.java:177)
at org.apache.fop.cli.Main.main(Main.java:208)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:300)
... 3 more
Caused by: org.apache.fop.fo.ValidationException: Property ID "idp8751564240" (found on "fo:wrapper") previously used; ID values must be unique within a document! (See position 6:48)
at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:58)
at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
at com.sun.proxy.$Proxy2.idNotUnique(Unknown Source)
at org.apache.fop.fo.FObj.checkId(FObj.java:173)
at org.apache.fop.fo.FObj.startOfNode(FObj.java:154)
at org.apache.fop.fo.flow.Wrapper.startOfNode(Wrapper.java:65)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:325)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
... 4 more
Am I doing anything wrong here? I appreciate any help!
Thanks in advance!
EDIT Here is the glosar_test.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<glossary id="glossar">
<title>Glossar</title>
<glossdiv id="gloss_E">
<title>E</title>
<glossentry id="gloss_etm-datei">
<glossterm id="glossterm_etm_datei">
<indexterm>
<primary>ETM-Datei</primary>
</indexterm>
<emphasis role="bold">ETM-Datei</emphasis>
</glossterm>
<glossdef>
<para>
Glossary_Text
</para>
</glossdef>
</glossentry>
</glossdiv>
</glossary>
I've found a solution!
At http://www.sagehill.net/docbookxsl/LinkToGlossary.html it is described how to reference to a gloassary. Normally, you would use the glossterm
-tag, e.g.:
<para>Set your <glossterm linkend="NetAddr">network address</glossterm>.
</para>
...
<glossary>
<glossentry id="NetAddr">
<glossterm>Network address</glossterm>
<glossdef><para>Four numbers separated by periods</para></glossdef>
</glossentry>
</glossary>
You also can use the link
or xref
-tag. If you use the xref-tag you must add an id
attribute to the glossterm and add a matching endterm attribute to the xref
element. For example:
<xref linkend="ge-xslfoprocessor" endterm="gt-xslfoprocessor"/>
...
<glossentry id="ge-xslfoprocessor">
<glossterm id="gt-xslfoprocessor">XSL-FO processor</glossterm>
<glossdef>
<para>Software component that converts an XSL-FO document into a
formatted document.</para>
</glossdef>
</glossentry>
If you do so, the ids of the fo:wrapper will be removed and fop can parse it to a pdf file.