سؤال

I was trying to convert a docbook document with fragmented/partial includes to pdf using Xerces 2.7.1 and Xalan 2.7.0.

<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>

This did not work until I figured out that in order to use partial includes one has to provide a resolveable path to the schemafile using <!DOCTYPE ..>.

But with Docbook 5.0 one should/has to use namespace declarations instead of DOCTYPE.

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
xml:lang="de" version="5.0" status="DRAFT" security="confidential"> 

How can I provide the docbookxi.rng to the toolchain?

هل كانت مفيدة؟

المحلول

There is no way to "provide the docbookxi.rng to the toolchain" that would help in this case. There isn't even a standard way to associate an XML document with a RELAX NG schema. The xmlns="http://docbook.org/ns/docbook" namespace declaration identifies the document as DocBook 5 (together with the version attribute), but it does not say anything about the location of the schema.

A line like this one,

<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>

means: "include the portion of TestDocument.included.xml that is identified by the element that has an attribute of type ID with a value of Section2".

In DocBook 5, xml:id is used for unique identifiers. This attribute is recognized as being of type ID, and there is no need for a schema to determine its "ID-ness" (see http://www.w3.org/TR/xml-id/). So if you have anyid attributes in your DocBook 5 documents, change them to xml:id.

Howewer, you should also make sure that the XML parser supports xml:id. Xerces seems to be lacking here, so it might still not work for you (see https://issues.apache.org/jira/browse/XERCESJ-1113).

If there are problems, you could try to use the DocBook 5 DTD (yes, there is a DTD even though the normative schema is written in RELAX NG). That DTD declares xml:id to be of type ID.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top