Skip to content

Support RELAX NG validation #450

Closed
Closed

Description

@tomschr

Situation

The README lists some validation with XSD and DTD. However, currently RNG (RELAX NG) isn't supported (doesn't show up in the list).

This makes it especially hard to write DocBook 5 documents, for example. DocBook 5 is based on RNG, there is no officially blessed DTD nor XSD available.

Proposed solution

It would be cool if RNG could be supported too like the other schema languages. For example, code completion, hover etc.

Further information

Activity

  1. fbricon commented on Apr 8, 2021

    @fbricon
    Collaborator
  2. angelozerr commented on Apr 8, 2021

    @angelozerr
    Contributor

    @tomschr thanks for creating this issue. As @fbricon mentionned, I started to implement XML validation based on RELAXNG in eclipse-lemminx/lemminx#841 PR, but it requires to add new JAR (Jing), so LemMinx JAR will grow up. This PR is just for XML validation based on RELAXNG.

    Providing a good support for RELAXNG (like we have for XSD / DTD) means:

    • XML completion based on RNG

    • XML validation based on RNG

    • XML hover based on RNG (documentation)

    • RNG completion (like we have for XSD complexType)

    • RNG validation to validate the RNG (not the XML bound woth RNG)

    • RNG references element

    • RNG rename element

    • RNG higlight for references element

    • RNG codelens for references element

    Same support for RNG compact. In this case it will require to implement a fault tolerant parser for RNG compact syntax since it doesn't follow the same syntax than XML.

    As you can see it's a lot of work! But if we see that we have a lot of people who are interested with RELAXNG we could try to start with XML validation based on RELAXNG.

    Please vote for this issue (like you did, thanks!)

    @tomschr have you tried https://marketplace.visualstudio.com/items?itemName=raffazizzi.sxml ? Could you give us feedback please.

  3. pgundlach commented on Apr 8, 2021

    @pgundlach

    Schematron support would be great as well.

    (I'd be happy to beta test rng support)

  4. angelozerr commented on Apr 8, 2021

    @angelozerr
    Contributor

    Schematron support would be great as well.

    Thanks for your feedback, could you create an another issue for that please because it's not the same topic than RELAXNG (just support another grammar kind). Thanks!

  5. tomschr commented on Apr 9, 2021

    @tomschr
    Author

    @angelozerr Hi Angelo,

    thanks for creating this issue. [...] I started to implement XML validation based on RELAXNG in eclipse-lemminx/lemminx#841 PR, but it requires to add new JAR (Jing), so LemMinx JAR will grow up. This PR is just for XML validation based on RELAXNG.

    Thank you for all your hard work. This is really appreciated! 👍 Yes, I've looked into this. It would be really great to see support for RELAX NG (RNG) as we need it for DocBook 5.

    have you tried https://marketplace.visualstudio.com/items?itemName=raffazizzi.sxml ? Could you give us feedback please.

    Yes, I've installed it and tried it with one of my XML files. I've created this little example:

    XML example file

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-model href="http://docbook.org/xml/5.1/rng/docbookxi.rng"
      type="application/xml"  schematypens="http://relaxng.org/ns/structure/1.0"?>
    
    <article version="5.1" xml:lang="en" xml:id="art-hpc-install"
      xmlns="http://docbook.org/ns/docbook"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:xlink="http://www.w3.org/1999/xlink">
        <title>Test</title>
        <para>The quick brown fox jumps over the lazy dog.</para>
    </article>

    Although it reports the XML as "XML is valid", it seems not to know or load the RNG.

    Placing the cursor after </para> and pressing Ctrl+Space opened a small popup with "Loading". Unfortunately, it seems, it couldn't find the related DocBook 5.1 RNG schema as it offers nothing more.

    However, DocBook 5.1 RNG is installed on my openSUSE Leap 15.1 system:

    $ xmlcatalog /etc/xml/catalog http://docbook.org/xml/5.1/rng/docbookxi.rng
    file:///usr/share/xml/docbook/schema/rng/5.1/docbookxi.rng
    

    I've added this XML catalog file into the VSCode setting key xml.catalogs, but it seems it wasn't used.

    To test if the plugin generally works and it's not a XML catalog problem, I've replaced the above official DocBook URI in href of xml-model with my local path. The result was the same.

    Another issue that I've discovered is the handling of the DOCTYPE declaration. This is okay:

    <!DOCTYPE article [
      <!ENTITY foo "FooFoo">
    ]>
    <!-- ... rest the same ... ->

    It even detects the foo entity when typing the ampersand. This is great! 👍

    However, when using a parameter entity, it fails (although foo.ent exists in the same directory):

    <!DOCTYPE article [
      <!ENTITY % ent SYSTEM "foo.ent">
      %ent;
    ]>
    <!-- ... rest the same ... ->

    Not sure if that helps. It was just a quick test and maybe I did something wrong or missed to configure it. Let me know if I can help you with more testing etc.

    I would have contributed even more, but I know nothing about Node.js or Java.

    Keep up this great work! 😍

    VSCode system details
    Version: 1.55.0
    Commit: c185983a683d14c396952dd432459097bc7f757f
    Date: 2021-03-30T16:02:21.560Z
    Electron: 11.3.0
    Chrome: 87.0.4280.141
    Node.js: 12.18.3
    V8: 8.7.220.31-electron.0
    OS: Linux x64 5.3.18-lp152.66-default
    
  6. tomschr commented on Apr 9, 2021

    @tomschr
    Author

    Schematron support would be great as well.

    could you create an another issue

    I've opened issue #451.

  7. fbricon commented on Oct 14, 2022

    @fbricon
    Collaborator

    Initial RelaxNG support is now available from vscode-xml pre-releases starting with v0.21.2022101304.
    Screenshot 2022-10-14 at 12 00 51

    Please give it a try and report any issues

  8. pgundlach commented on Oct 14, 2022

    @pgundlach

    How are RNG files associated? I've tried a catalog file and a reference to the rng file <?xml-model href="file:///Users/patrick/stuff/xml/changelog.rng" ?> in the xml-model PI.

  9. angelozerr commented on Oct 14, 2022

    @angelozerr
    Contributor

    How are RNG files associated? I've tried a catalog file and a reference to the rng file in the xml-model PI.

    It should work with:

    • only xml-model
    • with an XML catalog too if your XML have some namspace.

    If you write this comment, it doesn't work I suppose, is that?

    If it that, could you do the demo at eclipse-lemminx/lemminx#841 (comment) and tell us if it is working for you.

    If it is working for you and it doesn't work with your usecase, could you share your RNG and XML file.

  10. angelozerr commented on Oct 14, 2022

    @angelozerr
    Contributor

    @pgundlach please wait it seems that prerlease don't embed the RelaxNG support. Let us invesitgate why?

  11. angelozerr commented on Oct 14, 2022

    @angelozerr
    Contributor

    Ok, prerelease has been fixed, now you can install it and RelaxNG support should be available.

  12. tomschr commented on Oct 17, 2022

    @tomschr
    Author

    @angelozerr Thank you!
    In https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml, there is no RELAX NG in the "Feature" section mentioned. Maybe you want to update that? 🙂

  13. angelozerr commented on Oct 17, 2022

    @angelozerr
    Contributor

    @angelozerr Thank you!

    You are welcome!

    In https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml, there is no RELAX NG in the "Feature" section mentioned. Maybe you want to update that?

    Thanks for your suggestion, but I'm doing that in #787

    When release will be done, it will promote RelaxNG support.

  14. angelozerr commented on Oct 17, 2022

    @angelozerr
    Contributor
  15. angelozerr commented on Oct 19, 2022

    @angelozerr
    Contributor

    Fixed with eclipse-lemminx/lemminx#841

    We will create the release soon but now you can install the prerelease of vscode-xml.

    See documentation at https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/RelaxNGFeatures.md#relaxng-features

  16. added this to the 0.22.0 milestone on Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions