Page 1 of 1

Custom XML <--> Writer (with rules enforced while editing)

Posted: Sat Aug 01, 2015 4:58 pm
by User2348684
I have a custom XML format. Let's say it's a set of recipes. Those recipes have ingredients and preparation steps. Ingredients are listed at the top, and steps come after. I don't want to use an XML editor to manipulate the data, since I want users not to see the XML but to use a word processor's spell check, etc. I don't want users to have to do an extra step to convert the .odt file to the XML or vice-versa (they're not technical or can't be bothered). I also want the editor to enforce rules about the data, e.g., ingredients come first, preparation steps next, a recipe needs at least one ingredient and one step, etc.

There are products that do this, namely Xopus (which does it in a web page) - it's far from free (even though it started as an open-source project). Microsoft also has InfoPath (which seems to be exactly what I'm looking for). It was announced as discontinued in 2014. I'd like to make my solution open source and Googling pointed me several times to OO because of its XML filters.

XML import/export seems feasible with OO XML filters. However, I know that word processors like MSWord don't prevent or enforce semantics (the way paragraph styles can be used within a document). For example, users can insert an ingredient in the middle of the preparation steps, or make a recipe without ingredients, etc. In XML, these data rules are often specified in a schema (XSD). Xopus and InfoPath (mentioned above) work from an XSD file, but I'm not asking for a solution in OO that supports arbitrary XSD's (it's a really hard problem). The format of my data is fairly simple, but there are some rules about how the data are nested and structured and I'd like the editor to enforce them.

Here are some specific questions:
  • I read the XML Filters tutorial, but will OO writer enforce the rules?
  • I read some about XForms in OO, which might be the answer about rules. However, If I use them, it's not clear to me if:
    • there can be an arbitrary numbers of things (e.g. ingredients, steps)
    • there can be an arbitrary numbers of recipes (I got the impression a form would be limited to a single entry)
    • data inside the fields can be rich text that translates to CDATA HTML, e.g., bold, italics, and/or use of images inside ingredients or steps.
Are there any pointers to similar solutions/projects using OO? Is this even possible in OO? Did I miss other components of OO that might help?

Re: Custom XML <--> Writer (with rules enforced while editin

Posted: Sat Aug 01, 2015 6:43 pm
by Villeroy
The XML Filters tutorial, but will OO writer enforce the rules?
You are completely on your own here. Try out and tell us.
... XForms ...
I doubt that more than a dozend out of 100 Mio. users ever managed to do anything productive with OpenOffice XForms. I guess that many-to-many relations are supported in the same way as they are supported in database forms.
Theoretically, ODF is a clean XML document format. However, on this user forum the XMLness does not really matter (well, sometimes in spreadsheet context).

Re: Custom XML <--> Writer (with rules enforced while editin

Posted: Sun Aug 02, 2015 5:01 am
by User2348684
More Googling done, and I came across a mention of a tutorial with the exact same scenario, but with XML for VCF (instead of recipes). The actual tutorial is hard to find in English (IBM took it off line some time ago) but I found the source files on a Russian IBM site.
I read the XML Filters tutorial, but will OO writer enforce the rules?
When using XML Filters, OO Writer treats the data that's imported as any document. That means a user is free to modify the data in Writer, possibly breaking the data rules to which the XML is expected to be formatted. Using my first example for recipes, one could delete all ingredients, or move a paragraph representing an ingredient to the section of the document representing steps. As such, the export back to XML could fail or worse create an XML file that is invalid.