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 xml-model processing instruction #21

Closed
rosslamont opened this issue Aug 10, 2017 · 14 comments
Closed

Support xml-model processing instruction #21

rosslamont opened this issue Aug 10, 2017 · 14 comments

Comments

@rosslamont
Copy link
Contributor

I have created a new open source project ixvc (https://github.com/rosslamont/jxvc) which provides a JAXP compliant validator which can auto detect schema information from an xml file. It supports the usual suspects, (DTD and XSI) but particularly adds support for ISO/IEC 19757-11:2011 xml-model processing instructions, which in turn can load Relax NG and in theory Schematron and NVDL.

I'll set up a pull request with the necessary fixes.

@rosslamont
Copy link
Contributor Author

Actually, I'm holding off on the commit for now as it needs to sit on top of my existing pull request. Ping me if you want me to add them in or wait until you've dealt with my existing pull request.

rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Sep 21, 2017
@mricaud
Copy link

mricaud commented Oct 28, 2017

Just a word to say I'm really interrested in this feature ! I actually need to validate with the "unusual suspects" : Relax NG, NVDL and schematron (which is a really interresting triple for xml projects).

By the way I did not manage to make the Relax NG validation work (installing the 1.0.2-SNAPSHOT localy I still get an error : No SchemaFactory that implements the schema language specified by: http://componentcorp.com/xml/ns/xml-model/1.0 could be loaded) but I hope I find how to do it.

Do you mean to release the 1.0.2 on maven central soon ?

Anyway thanks for this work. I'm rather an XML developer, but I'll be happy to help.

Matthieu

@jochenw
Copy link
Member

jochenw commented Oct 28, 2017 via email

@rosslamont
Copy link
Contributor Author

rosslamont commented Oct 29, 2017 via email

@mricaud
Copy link

mricaud commented Nov 13, 2017

Hi Jochen, Hi Ross,

Thanks a lot for your answers and sorry for my late one. I finaly find time to test this Relax validation.
I add the dependencies to the plugin (actualy there seems to be a typo in your usage examples page : the artifactId is "jxvc" and not "ixvc" ?)

As attached file xml-validation-test.zip, please get my unit test.

When I run "mvn test":

  • The xsd validation works fine : I get a validation error and the test fails, which is what expected.
  • I don't get any errors from the rnc test at this points.
  • When I comment the xsd test to only let the rnc test, I then get :
    • an error when <validating> is set to true : "Cannot find the declaration of element 'counter'"
    • no errors (build success) when <validating> is not setted : It should actualy fails because I let an error in the xml file (content is not allowed).

Did I missed something in dependencies ? should I put them on the project instead of plugin dependency ? I tried to add jing as dependency but I get the same results.

Any tips welcome :)

Cheers
Matthieu

PS : by the way I was wondering if the PI's schematypens uri is important, I let the same as yours but in my real project I use this one (from oXygen IDE) :

<?xml-model href="../main/grammars/test.rnc" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>

@rosslamont
Copy link
Contributor Author

rosslamont commented Nov 24, 2017 via email

@mricaud
Copy link

mricaud commented Nov 25, 2017

Hi Ross,

Thanks for the bug raised. I tried with an absolute URI in the PI but I get the same result.
But maybe there's something else as you said.
Let's talk about this later after the bug is fixed.

Cheers
Matthieu

@rosslamont rosslamont added this to the Release 1.0.2 milestone Feb 1, 2018
@rosslamont
Copy link
Contributor Author

rosslamont commented Feb 12, 2018 via email

@mricaud
Copy link

mricaud commented Mar 2, 2018

Hi Ross,

Thanks a lot for your message, It works fine for me with the last release :)

Cheers
Matthieu

@mricaud
Copy link

mricaud commented Mar 2, 2018

I was then trying to go to next step with schematron validation (before nvdl :))
As you said it should theorically work ... I tried... but well I get this error:
test-sch.xml: No SchemaFactory that implements the schema language specified by: http://purl.oclc.org/dsdl/schematron could be loaded
xml-maven-validation-test.zip
Any ideas ?

PS : by the way I just found the w3c spec (non normativ) section about schematypens: https://www.w3.org/TR/xml-model/#dt-xml-model-processor#d0e689
Maybe those values could be used in instead of for instance "http://www.iana.org/assignments/media-types/application/relax-ng-compact-syntax" ?

@rosslamont
Copy link
Contributor Author

rosslamont commented Mar 6, 2018

Thanks Matthieu.

At the moment there are no JAXP compliant schematron or nvdl implementations that I know of. If you do know of one, then you should be able to simply add it as a dependency and jaxp libraries should in theory pick it up. Also, please let me know and I will work up some tests and make it work if it doesn't already. I hope to get time to implement these, but as I mentioned they are pretty non-trivial.

Regarding the w3 (and ISO) spec, looking at the code, this should already work, but I haven't run a test. Have you tried it (remember in this case you have to supply the "type" rather than "schematypens". If it doesn't work, I already raised a bug. Please add comments there.

@mricaud
Copy link

mricaud commented Apr 9, 2018

Hi Ross,

About schematron / NVDL validation, I tried to add a dependency to jing but it doesn't work. It should not be JAXP compliant. In my company we forked Jing-trang here: https://github.com/ELSGestion/jing-trang, that's why I really would like to use jing (one of the reason is that jing doen't support iso-schematron validation upon NVDL, which we use a lot...)

About the PI, I use:
<?xml-model href="../../test/samples/xf_infoCommentaire.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
Which works quite well :)

But I faced a validation problem: when the RNG schema has a namespace (grammar/@ns attribute) then the validation report this error:
found attribute "xmlns", but no attributes allowed here
And when deleting the xmlns I get this error (which is correct):
element "xxx" not allowed anywhere; expected element "xxx" (with xmlns="http://my/namespace")

Should I add a new bug here for namespace RNG schema support here ?

Thanks in advance
Matthieu

@rosslamont
Copy link
Contributor Author

rosslamont commented Apr 17, 2018

Hi Matthieu,

Under the covers, (in the jxvc project) I'm using the standard version of jing with a wrapper around it to make it jaxp compliant. If you have a fork of Jing-trang, you could copy my wrapper sub-projects to use your fork. I'm not sure if that will help you though.

Regarding that xmlns bug, I think I stumbled over that as well, but as I am just wrapping jing it would appear to be a jing bug. I'm unfortunately not sure what to do about it at this time. Perhaps you can look into your fork of jing and see where it might be?

Best Regards
Ross

@mricaud
Copy link

mricaud commented Jun 21, 2018

Hi Ross,

Sorry for this late answer. I use jing a lot (command line or via a IDE like Oxygen XML) and I never had this namespace problem. But I thought it could be linked to the jaxp compliance or something like that (which I don't really understand as a "non java" developer).

My colleague @jimetevenard did look deeper this problem and raised this issue.

I hope I'll be soon able to plug this plugin with my project and prevent unvalid xml to be commited (some of my collegues will hate me but I assume xml validity is important :))

And yes next step would be schematron validity, but as far as @jimetevenard told me, there's no jaxp compliant schematron validator (?). Let's see that later...

Best Regards
Matthieu

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

No branches or pull requests

3 participants