Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Relax NG #237

Closed
adunning opened this issue Nov 22, 2018 · 19 comments
Closed

Support for Relax NG #237

adunning opened this issue Nov 22, 2018 · 19 comments
Labels
CM Extension Content Model extension (XML Schema & DTD) completion This issue or enhancement is related to completion support enhancement New feature or request validation
Milestone

Comments

@adunning
Copy link

It would be absolutely brilliant if this project could reimplement the functionality of the Atom package at https://github.com/aerhard/linter-autocomplete-jing to provide validation and autocomplete for XML using Relax NG and Schematron. (This package uses Jing, which the Oxygen XML editor also uses for validation.) These schema languages are widely used by the Text Encoding Initiative and other complex encoding applications.

@fbricon fbricon added enhancement New feature or request CM Extension Content Model extension (XML Schema & DTD) completion This issue or enhancement is related to completion support validation labels Nov 22, 2018
@fbricon
Copy link
Contributor

fbricon commented Nov 22, 2018

Can probably be implemented as an extension. However, the team is stretched pretty thin at the moment so it'd be faster if someone provided a PR for that.

@adunning could you add a set of sample xml + schemas so we get an idea of how it works?

@angelozerr
Copy link
Contributor

angelozerr commented Nov 22, 2018

@adunning if you take us a sample with xml + schematron and a Java code which validate this xml file with Jing, it will help us a lot to add Schematron as an extension.

@adunning
Copy link
Author

Thank you! It's usually a matter of supporting <?xml-model> to associate a file with a schema. For example, a basic DocBook 5.1 file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://docbook.org/xml/5.1/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://docbook.org/xml/5.1/sch/docbook.sch" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<article xmlns="http://docbook.org/ns/docbook"
    xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
    <info>
        <title>Test file</title>
    </info>
    <sect1>
        <title>Test</title>
        <para>Sample text</para>
    </sect1>
</article>

In this case the Relax NG and Schematron schemata are in two separate files, but Schematron rules can also be embedded within an RNG schema, such as the example at https://github.com/DigitalLatin/caesar-balex/blob/master/balex-auto.xml (I can come up with many others).

The Atom package that validates such files mostly runs off a Java implementation at https://github.com/aerhard/xml-tools. It also provides a good set of test files at https://github.com/aerhard/linter-autocomplete-jing/tree/master/spec/validation/xml.

There is also a newer Java library at https://github.com/phax/ph-schematron/ that might be useful for Schematron support.

@angelozerr
Copy link
Contributor

angelozerr commented Nov 22, 2018

Thanks @adunning ! Is there any chance that you could contribute to this schematron support? I could help you if you wish to initialize the schematron extension.

@adunning
Copy link
Author

Sorry for the delayed response! That's an extremely kind offer; looking at the code, I don't think that I have sufficient skills with Java to write the entire thing, but I am certainly happy to test and help in any other way I can.

@zwaldowski
Copy link

After looking briefly into this, there are really two features here:

  • Allowing <?xml-model … ?> to specify schemas (of any type, not just RelaxNG) by adding a new CMPrologContentModelProvider to PrologPlugin.
  • Modifying XMLValidator to use SchemaFactory (example here) to allow additional schema language support to be discovered dynamically. It also allows binding multiple schema for a single document if we refactor a bit.

@angelozerr does that sound right to you? I'm not sure how the latter could be introduced through a plugin instead, because XMLValidator always runs on documents.

@angelozerr
Copy link
Contributor

angelozerr commented May 20, 2019 via email

@pgundlach
Copy link

This feature would be great. I would even think about spending some money for it, if it could help.

@ghost
Copy link

ghost commented Sep 19, 2019

Yes, it would be great, as it would allow a seamless use of TEI in VSCode with the RedHat XML extension.

@angelozerr
Copy link
Contributor

angelozerr commented Jun 25, 2020

Allowing to specify schemas (of any type, not just RelaxNG) by adding a new CMPrologContentModelProvider to PrologPlugin.

It's now supported for DTD and XSD.

@BalduinLandolt
Copy link
Contributor

@angelozerr am I right to assume that nobody is working on this at the moment? If so, I'd volunteer to give it a shot.
I would open separate issues for all the steps necessary. (According to the list suggested by @angelozerr in redhat-developer/vscode-xml#236 )

I did look into the Jing package a bit, and I'm confident I can get RelaxNG validation to work (rather easily, in fact). However, I would be greatful for some help/suggestion, how best to integrate it into Lemminx.

@angelozerr
Copy link
Contributor

@angelozerr am I right to assume that nobody is working on this at the moment?

I would like to study this issue when I will find time but if you can do that it would be very nice! Please do that and give us feedback.

The first issue to check is to verify if Jing and their dependencies can be used with EPL license. I think we must for Jing we will have to do open some CQ to use it but if it's not compatible with EPL we cannot use Jing.

An important thing, is the size of LemMinx uber jar if we include Jing and her dependencies.

I did look into the Jing package a bit, and I'm confident I can get RelaxNG validation to work (rather easily, in fact).

Great!

However, I would be greatful for some help/suggestion, how best to integrate it into Lemminx.

I think you should start managing validation with RelaxNG. The idea is to create a classe XMLModelRelaxNGValidator and call it in

I don't know if it will be possible with Jing. To study... Good luck!

@BalduinLandolt
Copy link
Contributor

I would like to study this issue when I will find time but if you can do that it would be very nice! Please do that and give us feedback.

Ok, I'll keep you updated. :)

The first issue to check is to verify if Jing and their dependencies can be used with EPL license. I think we must for Jing we will have to do open some CQ to use it but if it's not compatible with EPL we cannot use Jing.

Honestly, if I could leave the license question to somebody else, I would feel more at ease... That would be embarassing to mess up...

An important thing, is the size of LemMinx uber jar if we include Jing and her dependencies.

We'll have to see what difference it makes.

I think you should start managing validation with RelaxNG. The idea is to create a classe XMLModelRelaxNGValidator and call it in

Allright!

@datho7561
Copy link
Contributor

The latest snapshot of lemminx supports validating files using RelaxNG schemas.

If you would like to try it out in VS Code, you can try the prerelease version of vscode-xml, which should release at around 3 AM EST tomorrow.

If you have any feedback on it, feel free to open an issue.

@denismaier
Copy link

Does this also work for the compact format?

@datho7561
Copy link
Contributor

It should work with the compact format.

@adunning
Copy link
Author

This is absolutely fabulous; thank you! This is working perfectly with RelaxNG. I assume it does not yet include Schematron.

@angelozerr
Copy link
Contributor

angelozerr commented Oct 19, 2022

This is absolutely fabulous; thank you! This is working perfectly with RelaxNG.

Great thank you for your feedback. I think RelaxNG support should be improved again like validate RNC, RNG grammar, completion inside RNC, find definition in RNG, etc but validation, completion and hover in XML based on relaxNG should work.

Don't hesitate to create any issues to improve the support.

I assume it does not yet include Schematron.

Indeed we don't support Schematron. Please create an new issue for that, but I don't know when we will have time to do that.

This issue is fixed with #841

@angelozerr angelozerr added this to the 0.22.0 milestone Oct 19, 2022
@angelozerr angelozerr changed the title Support for Relax NG/Schematron Support for Relax NG Oct 19, 2022
@adunning
Copy link
Author

Thank you again – this will be transformative for users of the Text Encoding Initiative (TEI), which relies heavily on Relax NG and Schematron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CM Extension Content Model extension (XML Schema & DTD) completion This issue or enhancement is related to completion support enhancement New feature or request validation
Projects
None yet
Development

No branches or pull requests

8 participants