Page 1 of 1

Associating a RelaxNG schema with a framework by version

Posted: Tue Nov 02, 2010 10:45 pm
by dcramer
Hi there,
I've created a customization of the DocBook 5.0 schema and, following the advice of DocBook V5.0, The Transition Guide, http://www.docbook.org/docs/howto/#cust-naming, I'm using the version attribute to distinguish instances of my documents from straight DocBook documents:

Code: Select all

<book xmlns="http://docbook.org/ns/docbook" version="5.0-extension BroadBook-2.0">
In Oxygen, I've copied the DocBook framework and modified it to use my schema instead of the DocBook schema. By moving my new Document Type above the DocBook 5 document type in the list, I can cause my documents to open using my schema, however this also causes ALL DocBook documents to open using my schema. I don't see a way to specify which version attribute a Document Type should apply to. What am I missing?

Thanks,
David

Re: Associating a RelaxNG schema with a framework by version

Posted: Tue Nov 02, 2010 11:08 pm
by george
Dear David,

To match a framework based on an attribute value (an attribute of the root element) you need to implement a simple Java extension and set that in the Java class entry from an association rule.
Such an extension needs to implement the DocumentTypeCustomRuleMatcher interface that defines only one method:

Code: Select all


/**
* Check if the document type to which this custom rule belongs to
* should be used for the given document properties.
*
* @param systemID The system ID of the current file in an URL format with not allowed characters corrected.
* For example: "file:/C:/path/to/file/file.xml"
* @param rootNamespace The namespace of the root.
* @param rootLocalName The root local name.
* @param doctypePublicID The public id of the specified DTD if any.
* @param rootAttributes The root attributes. The attributes are DOM level 2
* and the namespaces are available for each one.
* @return <code>true</code> if the document type to which this rule belongs to
* will be used for the current file.
*/
boolean matches(
String systemID,
String rootNamespace,
String rootLocalName,
String doctypePublicID,
Attributes rootAttributes);
We have such an extension implemented for DITA that looks for the DITA architecture version attribute. The source is available in the oXygen Author SDK, look for the ro.sync.ecss.extensions.dita.topic.DITATopicCustomRuleMatcher class.

Best regards,
George

Re: Associating a RelaxNG schema with a framework by version

Posted: Wed Nov 03, 2010 4:22 pm
by dcramer
Thanks George for that quick reply. I'll give it a shot.

David

Re: Associating a RelaxNG schema with a framework by version

Posted: Tue Jan 25, 2011 10:58 pm
by dcramer
I haven't gotten around to trying this yet, but it occurs to me that it would be useful if in the Preferences, Document Type, in the Rules tab, in addition to Namespace, Root local name, etc, there were an "XPath Expression" field which let you put in something like "/*[@version = '5.0-extension BroadBook-2.0']". If that expression evaluates to true, then the schema is used.

Re: Associating a RelaxNG schema with a framework by version

Posted: Wed Jan 26, 2011 11:44 am
by Radu
Hi David,

Thanks for the suggestion.
In the meantime you can try to implement the DocumentTypeCustomRuleMatcher George mentioned and tell us if you run into any problems.

Regards,
Radu

Re: Associating a RelaxNG schema with a framework by version

Posted: Wed Feb 09, 2011 2:12 am
by dcramer
Btw., I ended up implementing this as you suggested and it turned out to be pretty simple to do.

Thanks,
David