Middleman form to validate xsd using backend code

I’m trying to do something with our current Middleman site at my company and I’m not sure how to go about it. I’m relatively new to ruby but I have a background in web development using microsoft libraries.

The goal is to build a page with a form on it. This form will allow users to input a sample of their xml data and have it validate against an xsd which contains our feed specifications. To do this, I have a method in ruby that I’ve written which does xsd validation against xml using Nokogiri. It works in command line and I’ve create a page that works exactly how I want it using Sinatra, but our documentation site is all done using Middleman so I need to figure out how to put something like this into Middleman.

Unfortunately there doesn’t seem to be a lot of similar cases out there and I’m beginning to think that Middleman is only meant to be a static html generator and not have any backend functionality. I hope I’m wrong.

I don’t know if this can be of any help @sanpaco but you might want to check out FormKeep and see if that with some of it’s integration apps will allow you to do what you want.

@dikaio Thanks for the reply. I had looked into that before but it looked like FormKeep was specifically tailored to be used to create submission forms for data models using more of an MVC approach. I really only need a submit, validate, and reply with validation results. That said I will look into FormKeep some more. Thanks again.

Middleman is a static site generator. So at the end of the day you are not hosting an application with which your users can interact and run ruby code in response to stuff. However, you could use javascript to get your xml info and do the validation on the client side or use a service which exposes an API to validate XML documents.

I looked into doing xsd checking in javascript and it was messy and complicated finding a good library to do it. Nokigiri does it with like 3 lines of code and is a widely distributed and familiar gem which is why I am trying to stick to that.

You could probably deploy a simple sinatra app which uses nokogiri and exposes your xsd checking on a url, deploy that to heroku and then use it from javascript on your static site.