Re: [Xsltforms-support] Off-line XForms
Brought to you by:
alain-couthures
From: Joe W. <jo...@gm...> - 2011-03-22 13:42:31
|
Alain, I have something that you might consider, if I understand you correctly. It handles elements and attributes, and flags mixed content as uneditable. Inspired by C.M. Sperberg-McQueen's "Introduction to XForms for XML Users" course, which was based around XSLTForms (see course materials at http://xforms201102.blackmesatech.com/), I decided to create a generic XML-to-XForms generator. The idea was to create a fairly generic "XML viewer" that would also let you edit content. It works well, except, of course, with mixed content - so I simply don't let nodes with mixed content be edited. I wrote this in the form of an XQuery application designed for eXist-db (I am using 1.5dev). I've attached the files here. Just unzip and drag the "xml2form" folder into your db (so you have /db/xml2form), and run http://localhost:8080/exist/rest/db/xml2form/xml2form.xq. This will pull up a form view of the "members.xml" file in the same directory. If you want to try running your own XML documents through, just use the "doc" URL parameter, e.g. xml2form.xq?doc=/db/path/to/file.xml. The part I'm happiest about is how it dynamically constructs the xf:input/@ref XPath value by counting ancestors - so if you view source on the generated code you'll see members[1]/member[2]/surname[1], etc. I also did a little extra work to make it work with namespaced documents, like TEI or DocBook documents. Hope you find it useful. Joe |