Docbook XSLT transformation

Oxygen general issues.
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Docbook XSLT transformation

Post by NicoAMP »

Hello,

I would like to create an XSL that resolves xi:include in a docbook document to get a single merged file.

Code: Select all

<!DOCTYPE book
  PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://docbook.org/xml/4.3/docbookx.dtd"[
<!-- Will use "m" as a prefix.-->
<!ENTITY % equation.content "(alt?, (graphic|mediaobject|m:math)+)">
<!ENTITY % inlineequation.content "(alt?, (graphic|inlinemediaobject|m:math)+)">
<!ENTITY % NS.prefixed     "INCLUDE">
<!ENTITY % MATHML.prefix   "m">
<!ENTITY % NamespaceDecl.attrib "
	xmlns:m
		CDATA	#FIXED 'http://www.w3.org/1998/Math/MathML'
">
<!-- Include the MathML DTD -->
<!ENTITY % mathml PUBLIC "-//W3C//DTD MathML 3.0//EN"
                  "http://www.w3.org/TR/MathML3/dtd/mathml3.dtd">
%mathml;
<!ENTITY % xinclude SYSTEM "http://www.docbook.org/xml/4.4/xinclude.mod" >
%xinclude;
]>
<book id="001" remap="FE" role="prosub" vendor="0000141792">
<title>XXX</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xxx.xml"><xi:fallback><!--Fallback markup for "x-wc://file=0000141793.xml"--></xi:fallback></xi:include>
</book>
In Oxygen I just use a transformation scenario with Saxon HE 11.4 with an identity XSL and it works like a charm:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
    version="2.0">
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
But when I tried to execute the same transformation in command line (outside of Oxygen) it doesn't work.

Code: Select all

java -cp "C:\xxx\Saxon-HE-main\11\Java\SaxonHE11-4J\saxon-he-11.4.jar" net.sf.saxon.Transform -xsl:"C:\xxx\flat.xsl" -s:"C:\xxx\book43.xml" -o:"c:/temp/xxx/out.xml" -t -xi:on -catalog:"C:\Program Files\Oxygen XML Editor 25 - 3\frameworks\docbook\catalog.xml"
I get the following error:

Code: Select all

SaxonJ-HE 11.4 from Saxonica
Java version 11.0.10
Stylesheet compilation time: 303.1586ms
Processing file:/C:/xxx/book43.xml
Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for file:/C:/xxx/book43.xml using class net.sf.saxon.tree.tiny.TinyBuilder
I/O error reported by XML parser processing file:/C:/xxx/book43.xml
It seems that the problem comes from doctype. Because if i remove it, it works!

I don't understand the difference between inside and outside execution.
Thanks for any help.
Regards
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Docbook XSLT transformation

Post by Radu »

Hi Nicolas,

The problem might be that Oxygen does not use Saxon from the command line, it invokes directly Java code from it so it may behave differently.
Another problem might be that Oxygen has lots of xml catalogs that it passes to the Saxon processor, almost each framework in the "OXYGEN_INSTALL_DIR/frameworks" folder contributes an XML catalog and we pass all these catalogs to Saxon.
For example you are using this entity reference:

Code: Select all

<!ENTITY % mathml PUBLIC "-//W3C//DTD MathML 3.0//EN"
                  "http://www.w3.org/TR/MathML3/dtd/mathml3.dtd">
Are you sure that the Docbook XML catalog ""C:\Program Files\Oxygen XML Editor 25 - 3\frameworks\docbook\catalog.xml"" resolves it? If not you need to add extra references to XML catalogs which resolve it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: Docbook XSLT transformation

Post by NicoAMP »

Hello Radu,

I resolved the problem importing the right catalog:

Code: Select all

java -cp "C:\xxx\Saxon-HE-main\11\Java\SaxonHE11-4J\saxon-he-11.4.jar" net.sf.saxon.Transform -xsl:"C:\xxx\flat.xsl" -s:"C:\xxx\book43.xml" -o:"c:/temp/xxx/out.xml" -t -xi:on -catalog:"C:\xxx\docbook\catalog.xml;C:\xxx\mathml\catalog.xml"
Thanks for your help.
Regards,
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Post Reply