IDREFs in document with XInclude

Oxygen general issues.
stilor
Posts: 6
Joined: Tue Jan 29, 2013 8:50 am

IDREFs in document with XInclude

Post by stilor »

Hi,

I am using oXygen 14 on DocBook sources which consist of several layers of documents included using XInclude, but I suspect it is probably the same with other document types with IDREF attributes.

In Author mode, when I edit an element that has an IDREF, I get a drop-down lists which offers the IDs of the elements in the current document. However, since the current file is just one of the sources, it is only a subset of all currently defined IDs.

An example:

<!-- book.xml -->
<book>
...
<xi:include href="ch1.xml"/>
<xi:include href="ch2.xml/>
</book>

<!-- ch1.xml -->
<chapter id="ch-overview">
...
</chapter>

<!-- ch2.xml -->
<chapter id="ch-next">
...
... <xref linkend="..."/>
</chapter>

In this example, if I edit <xref/> in ch2.xml, I only get "ch-next" in the drop-down list, but not "ch-overview". Is there a way to have oXygen provide the list of all the IDs ("ch-overview" and "ch-next", in this case)?
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: IDREFs in document with XInclude

Post by Radu »

Hi,

Are you editing Docbook 4 or Docbook 5 documents?

Your topic is similar to:

http://www.oxygenxml.com/forum/topic4079.html

Basically in order for Oxygen to know about the master file you would have to create a validation scenario:

http://www.oxygenxml.com/doc/ug-editor/ ... nario.html

which has two validation modules, one which validates the master file and one which validates the current module.
This should be enough for Oxygen to propose to you when editing the module all IDs detected starting from the master file.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
stilor
Posts: 6
Joined: Tue Jan 29, 2013 8:50 am

Re: IDREFs in document with XInclude

Post by stilor »

Radu wrote: Are you editing Docbook 4 or Docbook 5 documents?
Docbook 4 at this time.
Radu wrote: Your topic is similar to:
http://www.oxygenxml.com/forum/topic4079.html

Basically in order for Oxygen to know about the master file you would have to create a validation scenario:

http://www.oxygenxml.com/doc/ug-editor/ ... nario.html

which has two validation modules, one which validates the master file and one which validates the current module.
This should be enough for Oxygen to propose to you when editing the module all IDs detected starting from the master file.
Thanks. I configured a validation scenario with LIBXML, that is successful. But if I use default engine, it fails:

- there is a lot of 'Unexpected element xi:include' because Xerxes still tries to validate before resolving XIncludes
- In addition, the document uses XPointer scheme for XInclude, which is not supported by Xerxes either.

Because of validation failure, I guess, the drop-down list is completely empty.

That topic you referred to topic is from 10 years ago, but apparently, nothing has changed.
stilor
Posts: 6
Joined: Tue Jan 29, 2013 8:50 am

Re: IDREFs in document with XInclude

Post by stilor »

I've modified the DTD to include xi:include into the list of available elements for each parent element, as described here, and temporarily remove the XIncludes with XPointer scheme.

Now, there are no errors due to inclusion of the files. Yet, the default engine gives a lot of warnings wherever there is a link between different parts of the document, e.g.:

master file:

Code: Select all


<book>
...
<xi:include href="ch_overview.xml"/>
<xi:include href="ch_tools.xml"/>
</book>
ch_overview.xml:

Code: Select all


<chapter>
...
<!-- Default validation engine produces an error on xref below -->
<para>Refer to <xref linkend="ch-tools"/>...</para>
</chapter>
ch_tools.xml:

Code: Select all


<chapter id="ch-tools"/>
...
</chapter>
The errors are of the form:
An element with the identifier "ch-tools" must appear in the document.

Why isn't it picking up the IDs from other files, even though it is validated from the "top-level" file?
stilor
Posts: 6
Joined: Tue Jan 29, 2013 8:50 am

Re: IDREFs in document with XInclude

Post by stilor »

I re-read the previous topic and found a response that the root cause is that DB4 is validated using DTD, so it is validated "one file at a time".

Ok, then the question becomes: would it be possible to configure oXygen to perform two-step validation: process XInclude using libxml, then validate the output using default engine to pick up element IDs?
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: IDREFs in document with XInclude

Post by Radu »

Hi,
I re-read the previous topic and found a response that the root cause is that DB4 is validated using DTD, so it is validated "one file at a time".
You are spot on.
If your Docbook 4 documents were XML Schema based (or if you would use Docbook 5 XML Schema or Relax NG based) the default XML validator (Xerces) would first expand the xi:included modules and then validate so a validation on the main document would validate everything like it would be a single document.

But DTDs and XML are very closely connected and when the default XML validator expands the DTD associated to an XML file (to solve ay entity references that could occur in the XML) it also validates the file before the xi:include sections have been processed.

I'll try to increase the priority to the issue which is already opened on our side, try to delay the validation until the xi:include sections have been expanded.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: IDREFs in document with XInclude

Post by Radu »

Hi,

We released Oxygen 15.0 a couple of days ago.
In oxygen 15.0 we added a feature called:

Code: Select all


    Post XInclude Processing DTD Validation
When XML documents using DTDs are assembled using XInclude, the default validation behavior is now to first assemble all documents in a master document and then validate the master document using the referenced DTD.
Basically this would mean that by default the Xerces DTD validation of the master XML document is done after all xi:include documents are resolved and all IDs are collected.

So this feature (which is enabled by default) should fix the issues reported in this thread.

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