0

I am creating a tool that allows someone to input recipes which should then be saved as an XML file, I have created my XSD but I was wondering how I can make a form on my web page that will allow the user to enter their recipe and adhere to the schema. I have been looking into Ajax and Jquery but am really confused. Any help would be much appreciated!

Nick

1
  • I known infopath can do this, but it's a commercial package from M$ Commented Nov 13, 2013 at 11:01

3 Answers 3

1

Your information is a bit minimal. So if I'm stating the obvious my apologes. The basic approach would be to create a page that implements all your data elements. Use javascript/Jquery to validate requiered elements. After sending the page to the server read all elements and create a XML document.

You didn't specify your server handling language, but this approach can be used with any of the known languages such as PHP, C#, VB.NET, Ruby, Perl.

Depending on your choice creating and maintaining the template code of the page is less or more work. You could also use XSLT to generate a HTML page from the XSD. Reading data can also be done with XSLT. If you use the Smalltalk web application framework Seaside, pages are generated from code, so there is only one place to maintain your application. But that is not really widely used so that might not be an option. Most other languages use templates for pages.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry for the minimal information, when you say create a page that implements all my data elements would that be a html form? Thanks for the help
Yes, with page I mean a HTML form.
1

You can do that by the following code: The following code check if file not exists then create xml if not then load the created xml file.

    string file = MapPath("~/Recepies.xml");

    XDocument doc;

    //Verify whether a file is exists or not
    if (!System.IO.File.Exists(file))
    {
        doc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
            new System.Xml.Linq.XElement("Recepies"));
    }
    else
    {
        doc = XDocument.Load(file);
    }

    XElement ele = new XElement("Recepie", txtRecepie.Text.Trim());
    doc.Root.Add(ele);
    doc.Save(file);

    using (StreamWriter writer = new StreamWriter(Response.OutputStream, new UTF8Encoding(false)))
    {
        doc.Save(writer);
        Response.ContentType = "text/xml";
        Response.AddHeader("Content-disposition", "attachment;filename=file.xml");
        Response.Flush();
        Response.End();
    }

Comments

0

Try the tool http://github.com/davidmoten/xsd-forms. It generates HTML and JavaScript based on an xsd and submits XML compliant with the xsd.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.