mojohaus / xml-maven-plugin

XML Maven Plugin
https://www.mojohaus.org/xml-maven-plugin/
Apache License 2.0
23 stars 21 forks source link

Support xml-model processing instruction #21

Closed rosslamont closed 7 years ago

rosslamont commented 7 years ago

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 commented 7 years ago

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.

mricaud commented 7 years ago

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 commented 7 years ago

On Sat, Oct 28, 2017 at 10:51 PM, Matthieu Ricaud-Dussarget < notifications@github.com> wrote:

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.

Sounds like a missing dependency to me.

Jochen

rosslamont commented 7 years ago

Hi Matthieu,

I really should put an example in the documentation. :-)

The long and short is that the plugin needed some code changes to support the JAXP compliant xml-model validator I created, but it does not mandate any particular implementation, so it has no built in dependency. See https://github.com/rosslamont/jxvc https://github.com/rosslamont/jxvc and https://github.com/rosslamont/jxvc/wiki/Usage-examples https://github.com/rosslamont/jxvc/wiki/Usage-examples for examples of the dependencies you might need. Sadly, I don’t have, nor can I find any NVDL or schematron implementations, but in theory ixvc should support any third party validator. I’m hoping to work on those validators later (after I have an external DTD validator going), but they are pretty non-trivial.

You’ll probably need to add the dependencies directly to the plugin declaration in your pom, but it should probably work as a test dependency too.

Cheers Ross

On 29 Oct 2017, at 7:51 am, Matthieu Ricaud-Dussarget notifications@github.com wrote:

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 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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mojohaus/xml-maven-plugin/issues/21#issuecomment-340219023, or mute the thread https://github.com/notifications/unsubscribe-auth/AXKC2NNCDCC3CGiOX5nIoljbWTn5lXDWks5sw5PGgaJpZM4Oy6y_.

mricaud commented 7 years ago

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":

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 commented 6 years ago

Hi Matthieu,

I raised bug 34 https://github.com/mojohaus/xml-maven-plugin/issues/34 on this. There are also a few problems in your project, but I’ll respond to them once the fix has been merged in.

Thanks for the ixvc pointer - corrected.

Best Regards Ross

On 13 Nov 2017, at 7:44 pm, Matthieu Ricaud-Dussarget notifications@github.com wrote:

Hi Ross,

Thanks a lot for your answer 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 https://github.com/mojohaus/xml-maven-plugin/files/1466078/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 is set to true : "Cannot find the declaration of element 'counter'" no errors (build success) when 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"?>

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mojohaus/xml-maven-plugin/issues/21#issuecomment-343849996, or mute the thread https://github.com/notifications/unsubscribe-auth/AXKC2HADQKbN59HjT5qiQaIJczOxqXU_ks5s2AFigaJpZM4Oy6y_.

mricaud commented 6 years ago

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 commented 6 years ago

Hi Matthieu,

I’ve finally gotten that bug sorted and there is now a release out there with the fix in (1.0.2-beta-1). No example code yet but there is a bug raised for that.

Cheers Ross

On 25 Nov 2017, at 9:22 pm, Matthieu Ricaud-Dussarget notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mojohaus/xml-maven-plugin/issues/21#issuecomment-346931828, or mute the thread https://github.com/notifications/unsubscribe-auth/AXKC2NKrbvDBzomH4iGVjigbPVpwRV4Wks5s5-pQgaJpZM4Oy6y_.

mricaud commented 6 years ago

Hi Ross,

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

Cheers Matthieu

mricaud commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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