Extend RNG schema

Post here questions and problems related to oXygen frameworks/document types.
gravyboat
Posts: 7

Extend RNG schema

Fri Sep 16, 2011 10:33 pm

Hi,
I was wondering if it's possible to extend RNG validation; we have a number of elements in a custom namespace that we include within <a:documentation>, and I would like to enable validation and content completion for these.

Is this possible?
george
Site Admin
Posts: 2100

Re: Extend RNG schema

Wed Sep 21, 2011 4:06 pm

Hi,

Yes, that is possible.
You need to create a validation scenario and for one of the validation units add the default Relax NG validation and for the other add a validation of the schema as XML document specifying the schema you want to validate against. Please note that this schema should handle the whole Relax NG schemas as if that would be an XML document - one simple approach is to use NVDL to determine the fragments from your namespace and validate them with your schema.
If you need help with the NVDL script I would be happy to help you.

Please note that Relax NG supports annotations as elements from a foreign namespace but you should not place them inside the a:documentation annotation as that is defined by the Relax NG DTD compatibility specification to contain only text.

Best Regards,
George
George Cristian Bina
gravyboat
Posts: 7

Re: Extend RNG schema

Thu Sep 22, 2011 4:26 pm

Thanks George.

I've followed the examples found in the forums and have created an NVDL file, as well as a custom RNG schema for RNG that includes our special documentation elements (which I've removed from a:documentation). I've associated the RNG document type with the custom RNG schema and validation now works.

I'm unclear on what the NVDL script does -- by doing the document type association it seems I no longer need this, is that right?

Although validation works the content completion does not. In fact, I removed the a:documentation element from the custom RNG schema for RNG but I still see it in the content completion box. I've tried referencing the NVDL script from the custom RNG schema, but that appears to make no difference.

Obviously I'm doing something wrong; any help is appreciated.
george
Site Admin
Posts: 2100

Re: Extend RNG schema

Thu Sep 22, 2011 5:07 pm

My answer was for your initial question regarding validation. The content completion for the Relax NG schemas is built-in. That however is based on the Relax NG schema for Relax NG and you can overwrite that with a different Relax NG schema following the procedure below - please note that in this case an NVDL script will not work, only an additional Relax NG schema that covers also the annotation language:

- create a folder named "builtin"
- place your updated Relax NG schema there and name it "relaxing.rng"
- pack this in a jar or zip archive (the archive should contain the builtin folder)
- place this archive in [oxygen]/lib/endorsed - you need to create the endorsed folder because it does not exist by default
- restart oXygen

Please note that this is not the usual user configuration as you are overwriting built-in resources in this way and if you place there a broken schema then some functionality from oXygen will break.

Coming back to your initial topic, if you created an updated Relax NG schema that defines also the annotation elements then you do not need an NVDL script. An NVDL script is needed only if you want to use the Relax NG schema for Relax NG without any change and you have a schema for your annotation markup. The NVDL script can validate only the content from your annotation namespace with your annotation schema and also validate the complete Relax NG schema with the schema for Relax NG.

If you need more detailed help please send me your schemas and a more detailed description of what you did and I will look over that.

Best Regards,
George
George Cristian Bina
gravyboat
Posts: 7

Re: Extend RNG schema

Thu Sep 22, 2011 9:10 pm

I've followed your instructions but it hasn't made any noticeable difference. A couple more questions for you:

* are the content completion and validation separate issues with separate solutions, or will the .jar file technique accomplish both?

* should the .jar/.zip archive created per above have any specific filename? (I've tried 'relaxing.jar' and 'endorsed.jar')

* is placing the .jar in the [oxygen]/lib/endorsed directory all that needs to be done, or is there additional configuration required?

* is there a way for me to send you my schema privately?

My goal is mainly to have my documentation elements appear in the content completion, for validation I can get by with a custom Validation Scenario (although having this be the default for all .RNG files would be preferable).

Thanks again.
george
Site Admin
Posts: 2100

Re: Extend RNG schema

Thu Sep 22, 2011 9:30 pm

The default Relax NG validation is not a validation against a schema... The validation tries to get a pattern from the Relax NG schema and thus it performs a number of other checks that cannot be covered by a Relax NG schema so the built-in/relaxng.rng is not used for Relax NG schema validation, it is only used for content completion.
oXygen looks automatically in the lib/endorsed folder and loads all the libraries it finds there before the normal libraries from the lib folder so basically by placing the schema as I described you will overwrite the schema from the oXygen library. That should be all to update the content completion support.

One possibility to get the validation scenario as default for any Relax NG schema it to add it in Options->Preferences -- Document Type Association, select Relax NG and use the Edit action then add the validation scenario in the Validation tab and mark it as default scenario so that it will be associated automatically with any Relax NG schema.
For portability you can place your schema in [oxygen]/frameworks/relaxng/ann.rng and then use as schema in the validation scenario
${frameworks}/relaxng/ann.rng

You can send your schema to support at oxygenxml.com.

Best Regards,
George
George Cristian Bina
gravyboat
Posts: 7

Re: Extend RNG schema

Thu Sep 22, 2011 10:06 pm

After reading your last post I figured there may have been a typo above, so I renamed my schema from "relaxing.rng" to "relaxng.rng" and re-zipped and now it works as expected.

Thanks again for all your help
george
Site Admin
Posts: 2100

Re: Extend RNG schema

Thu Sep 22, 2011 10:57 pm

Great to hear that you got that working!
If you place also the validation scenario in the Relax NG framework as I described then you should have everything set.

Best Regards,
George
George Cristian Bina
gravyboat
Posts: 7

Re: Extend RNG schema

Fri Oct 14, 2011 4:53 pm

Sorry to reopen this, but I notice that attributes (either required or optional) are not being shown in content completion; any tips? I've tried both referencing attributes from another <define> pattern and declaring them directly within <attribute> declarations.
Radu
Posts: 5689

Re: Extend RNG schema

Thu Oct 20, 2011 10:12 am

Hi,

Are you referring to attributes not being shown when editing the Relax NG schema or an XML instance?

If you are referring to an XML instance:

If you define attributes for an element in Relax NG (XML or compact) Oxygen should propose you those attributes when content completion is invoked.

See this sample RelaxNG schema as a sample for defining attributes:

OXYGEN_INSTALL_DIR/samples/relaxng/personal.rng

and the personal.xml file located in the same directory which presents attributes when content completion is invoked on an element.

In what page are you editing? Text or Author?
Are the attributes shown in the Attributes view?

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

Re: Extend RNG schema

Thu Oct 20, 2011 4:17 pm

I'm referring to when editing an RNG schema -- as described in this thread, I've extended the RNG schema to add documentation structures from a custom namespace. The RNG schema is then validated as if it were an XML instance using a custom validation scenario.

All of the documentation elements are showing in content completion, but not the attributes. The attributes do not show in the "Attributes" window.
Radu
Posts: 5689

Re: Extend RNG schema

Thu Oct 20, 2011 5:07 pm

Hi,

So from what I understand you used the method of modifying the "relaxng.rng" and placing it in a new folder path called OXYGEN_INSTALL_DIR/lib/endorsed/builtin.
Note that you do not have to zip the schema. Just create the folder path and place it in there.

You can send your modified version of the "relaxng.rng" to our support email address (support@oxygenxml.com) along with a sample RelaxNG instance and we'll take a look.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
george
Site Admin
Posts: 2100

Re: Extend RNG schema

Mon Oct 31, 2011 1:48 pm

Please let us know if you still have problems with this. There is nothing oXygen does specially for the other attributes defined in the relaxng.rng so your attributes should be presented as any other attributes.
One thing you can try is to rename your Relax NG schema as test.xml and associate your modified relaxng.rng schema with that file using an xml-model PI and see if you get a different behavior or if you can identify an eventual problem.
As Radu mentioned, if you can send us your schema or a sample showing the same problem we will look into that.

Best Regards,
George
George Cristian Bina

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 2 guests