Discussion:
[go-nuts] XSD Validation
krolaw
2015-02-19 21:35:25 UTC
Permalink
Hi,

I'm looking for a way to allow a go web service to check input XML against
a provided XSD schema, before forwarding it on to another service.

Does anyone have some example code that validates xml from a provided
schema?

I thought the easiest way forward would be to find a package that wraps
libxml2. However, either the wrappers I have looked at are incomplete, or
I'm ignorant on how to call the various functions to schema validate xml.

Suggestions gratefully appreciated.

Thanks.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Feyyaz Esatoglu
2015-02-19 23:41:10 UTC
Permalink
https://github.com/metaleap/go-xsd it looks like what you need

"With this, you could probably write an XML validator, or otherwise utilize
or further process the loaded XSD --- but the main use-case here was:"
Post by krolaw
Hi,
I'm looking for a way to allow a go web service to check input XML against
a provided XSD schema, before forwarding it on to another service.
Does anyone have some example code that validates xml from a provided
schema?
I thought the easiest way forward would be to find a package that wraps
libxml2. However, either the wrappers I have looked at are incomplete, or
I'm ignorant on how to call the various functions to schema validate xml.
Suggestions gratefully appreciated.
Thanks.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
krolaw
2015-02-20 02:14:53 UTC
Permalink
Unfortunately, the XSD may be supplied as user data. Having it compiled in
isn't desirable. It's pretty cool, but not applicable for this purpose.

Thanks.
Post by Feyyaz Esatoglu
https://github.com/metaleap/go-xsd it looks like what you need
"With this, you could probably write an XML validator, or otherwise
utilize or further process the loaded XSD --- but the main use-case here
was:"
Post by krolaw
Hi,
I'm looking for a way to allow a go web service to check input XML
against a provided XSD schema, before forwarding it on to another service.
Does anyone have some example code that validates xml from a provided
schema?
I thought the easiest way forward would be to find a package that wraps
libxml2. However, either the wrappers I have looked at are incomplete, or
I'm ignorant on how to call the various functions to schema validate xml.
Suggestions gratefully appreciated.
Thanks.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
krolaw
2015-02-26 08:39:51 UTC
Permalink
Hi,

I didn't have any luck finding a Go XML Schema validation solution, so I
thought I would try my hand with CGO and write a libxml2 wrapper myself.
Whilst I can validate, I can't extract the error messages on failure. I
was wondering if someone who is familiar with CGO would have a look at my
coding attempts and offer some guidance (and any other feedback deemed
appropriate).

The project is at:
https://github.com/krolaw/xsd

Many thanks.
Post by krolaw
Hi,
I'm looking for a way to allow a go web service to check input XML against
a provided XSD schema, before forwarding it on to another service.
Does anyone have some example code that validates xml from a provided
schema?
I thought the easiest way forward would be to find a package that wraps
libxml2. However, either the wrappers I have looked at are incomplete, or
I'm ignorant on how to call the various functions to schema validate xml.
Suggestions gratefully appreciated.
Thanks.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Konstantin Khomoutov
2015-02-26 09:46:28 UTC
Permalink
On Thu, 26 Feb 2015 00:39:51 -0800 (PST)
Post by krolaw
Hi,
I didn't have any luck finding a Go XML Schema validation solution,
so I thought I would try my hand with CGO and write a libxml2 wrapper
myself. Whilst I can validate, I can't extract the error messages on
failure. I was wondering if someone who is familiar with CGO would
have a look at my coding attempts and offer some guidance (and any
other feedback deemed appropriate).
https://github.com/krolaw/xsd
Sorry, have no time to look at your code, but did you look at already
available libxml2 bindings [1, 2]? They might have implemented this
aspect already.

By the way, goxml looks particularly comprehensive. May be it worth
getting in touch with the authors of these packages and discuss
contributing your code into one/both of them? I mean, too much
fragmentation is not very good, and IMO it would be better to have a
single package exposing most of libxml2 than three packages each
exposing just some bits of it.

P.S.
I've found these packages by searching on [3].

1. https://github.com/martende/goxml
2. https://github.com/teejae/go-libxml
3. http://godoc.org
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Richard Warburton
2015-02-26 10:17:02 UTC
Permalink
Hi,

Thanks for your email. I have searched previously myself. The two links
provided don't do schema validation.

I have found one author who was interested in having such functionality
contributed. However, all the wrapper libs I have looked at just expose
the C functions, and don't feel like go libraries (i.e. no second return
value for errors). Because I'm going in a different direction, my code
probably won't fit well with existing libraries. But I'll ask anyway.

In any case, I don't have much to show unless I can expose validation
errors.

Cheers.

On 26 February 2015 at 22:46, Konstantin Khomoutov <
Post by Konstantin Khomoutov
On Thu, 26 Feb 2015 00:39:51 -0800 (PST)
Post by krolaw
Hi,
I didn't have any luck finding a Go XML Schema validation solution,
so I thought I would try my hand with CGO and write a libxml2 wrapper
myself. Whilst I can validate, I can't extract the error messages on
failure. I was wondering if someone who is familiar with CGO would
have a look at my coding attempts and offer some guidance (and any
other feedback deemed appropriate).
https://github.com/krolaw/xsd
Sorry, have no time to look at your code, but did you look at already
available libxml2 bindings [1, 2]? They might have implemented this
aspect already.
By the way, goxml looks particularly comprehensive. May be it worth
getting in touch with the authors of these packages and discuss
contributing your code into one/both of them? I mean, too much
fragmentation is not very good, and IMO it would be better to have a
single package exposing most of libxml2 than three packages each
exposing just some bits of it.
P.S.
I've found these packages by searching on [3].
1. https://github.com/martende/goxml
2. https://github.com/teejae/go-libxml
3. http://godoc.org
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...