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

Add code action to generate RelaxNG grammar #1426

Merged

Conversation

JessicaJHee
Copy link
Contributor

Peek 2022-12-19 16-07

Fixes #1405

Signed-off-by: Jessica He jhe@redhat.com

@JessicaJHee
Copy link
Contributor Author

Currently I have the start of the generated file as:

<?xml version="1.0" encoding="UTF-8"?>
<element name="rootElementName" xmlns="http://relaxng.org/ns/structure/1.0">
...

I see in other examples they have something like :

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" 
         xmlns:sch="http://purl.oclc.org/dsdl/schematron"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <start>
        <element name="rootElementName">
        ...

I wonder if the second case is better/more accepted?

@angelozerr
Copy link
Contributor

angelozerr commented Dec 19, 2022

It looks promising !

I think you should generate grammar element because

  • the most rng file that I have seen uses grammar
  • we have a snippet in rng file which generates grammar. To be consistent with this snippet I think it is better to generate grammar element

In your demo you generate an rng prefix. I think yuu should generate without prefix. Please see the rng snippet

@JessicaJHee JessicaJHee force-pushed the generate-relaxng-grammar branch from 59a072e to 6816c80 Compare December 19, 2022 21:44
schema.startPrologOrPI("xml");
schema.addContent(" version=\"1.0\" encoding=\"UTF-8\"");
schema.endPrologOrPI();
// <element name="rootElementName" xmlns:rng="http://relaxng.org/ns/structure/1.0">
Copy link
Contributor

@angelozerr angelozerr Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please generate the same content than snippet https://github.com/eclipse/lemminx/blob/main/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/services/snippets/new-rng-snippets.json

  • without rng prefix
  • with grammar element
  • with datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  • with define pattern

Signed-off-by: Jessica He <jhe@redhat.com>
@JessicaJHee JessicaJHee force-pushed the generate-relaxng-grammar branch from 6816c80 to 92a0eec Compare December 21, 2022 16:04
@JessicaJHee JessicaJHee marked this pull request as ready for review December 21, 2022 16:04
@angelozerr
Copy link
Contributor

The PR looks very good. If CI build works I m OK to merge the PR.

We will improve it and fix bugs on another PR

@JessicaJHee JessicaJHee merged commit 5eed8d7 into eclipse-lemminx:main Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeAction to generate RelaxNG RNG file
2 participants