Add a document type for a custom RNG schema with a custom URN

Graydon2014
Posts: 4
Joined: Tue May 20, 2014 6:55 pm

Add a document type for a custom RNG schema with a custom URN

Post by Graydon2014 » Fri May 10, 2019 7:24 pm

Hi --

The overall goal here is to get Author to recognize the document type so we can add some custom CSS extensions.

In oXygen 21, I've created a custom extension framework; there's a directory with custom DITA schemas (which are complete document types) and a catalog file, and a sibling directory of templates.

This part works; I can create a new DITA document based on the templates, and they validate correctly based on the extension framework's catalog associations to schemas in the extension framework.

What I'm not getting is a document type association; the Properties view shows a Document type value for a default DITA document created in the context of the extension framework, while a document create for one of the custom document types gets no Document type property at all.

If I go to Options->Preferences->Document Type Association, select the custom framework, hit Edit, and look at the "Associations" tab, it's not at all clear how I use a URN public ID to associate the custom documents with a document type. (I'm a little worried that there's detection of the OASIS standard URNs in the custom java class, but non-OASIS URNs are effectively invisible.)

What should I be doing (at the "URN goes here" level!) so the custom RNG schemas have a document type so Author knows how to style them?

Thanks!
Graydon

Radu
Posts: 6179
Joined: Fri Jul 09, 2004 5:18 pm

Re: Add a document type for a custom RNG schema with a custom URN

Post by Radu » Mon May 13, 2019 3:05 pm

Hi Graydon,

We do not have a framework-specific association rule to state that it matches an xml document only if its xml-model processing instruction references a certain schema. I will add an internal issue to consider adding something like this.
Two possible workarounds:
1) If end users will only work with your custom framework configuration, in the Preferences->"Document Type Associations" page edit your framework customization and set its priority to "High" so that it will be the first framework which will be tested (and probably matched) when opening the XML document.
2) If you add/edit an association rule in the framework customization dialog, there is the possibility to use a custom Java API class to improve the detection:

https://www.oxygenxml.com/InstData/Edit ... tcher.html

so you could create a custom implementation of the "DocumentTypeAdvancedCustomRuleMatcher" interface (our Oxygen SDK contains all the necessary JAR libraries to compile your implementation), create a JAR library with your implementation, copy the JAR to the framework folder, add a reference to the JAR in the "Classpath" tab and then use the implementation from the JAR in the association rules.

One of the callback methods in the new API:

Code: Select all

public boolean matches(java.lang.String systemID,
                       java.lang.String rootNamespace,
                       java.lang.String rootLocalName,
                       java.lang.String doctypePublicID,
                       org.xml.sax.Attributes rootAttributes,
                       java.io.Reader contentReader)
sends you the entire "contentReader", a reader over the XML content which could be used by you to perform the detection yourself.

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

Graydon2014
Posts: 4
Joined: Tue May 20, 2014 6:55 pm

Re: Add a document type for a custom RNG schema with a custom URN

Post by Graydon2014 » Mon May 13, 2019 3:48 pm

Thanks, Radu!

Association rules using xml-model would be extremely useful.

(No luck with setting the priority on the custom extension framework to "high"; no document type, and no CSS association.)

chrispitude
Posts: 19
Joined: Thu May 02, 2019 2:32 pm

Re: Add a document type for a custom RNG schema with a custom URN

Post by chrispitude » Tue May 14, 2019 2:12 am

This is interesting; I didn't know you could provide a DITA schema using a custom framework. Does that relieve users from having to put it in the plugins/ folder of the DITA-OT installation inside the Oxygen XML directory?

Radu
Posts: 6179
Joined: Fri Jul 09, 2004 5:18 pm

Re: Add a document type for a custom RNG schema with a custom URN

Post by Radu » Tue May 14, 2019 7:21 am

Hi,

About this remark:
No luck with setting the priority on the custom extension framework to "high"; no document type, and no CSS association
This means that the association rules set on your custom framework (which by now should be the first one in the list) do not match at all the XML files you are opening. So you would need to find out why this is.

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

Radu
Posts: 6179
Joined: Fri Jul 09, 2004 5:18 pm

Re: Add a document type for a custom RNG schema with a custom URN

Post by Radu » Tue May 14, 2019 7:29 am

About Chris' remark:
This is interesting; I didn't know you could provide a DITA schema using a custom framework. Does that relieve users from having to put it in the plugins/ folder of the DITA-OT installation inside the Oxygen XML directory?
An extension of the DITA framework can provide its own XML catalog which may resolve its DTD public IDs (or references to XML or RNG Schemas) to some custom locations.
This will make validation and editing inside Oxygen work but this will not make publishing work as the publishing is still done with the DITA OT which looks for XML catalog mappings in only one place, in its "catalog-dita.xml" XML catalog file.
So if you also want to make publishing work you need to install a DITA OT plugin with the specialization.

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

Post Reply