Seeking enlightment: Given an XML document, can one create a generic web application (let's say, just one page) to edit the XML document? Let me give an example, say the XML is (I'm mixing up attributes and sub-elements just for demo, not necessarily making sense):
<person name="Jack" age="35">
<phone type="home" value="5551112222"/>
<phone type="cell" value="5552223333"/>
</person>
Now I'd like a web page that allows changing the attribute/elements. If fancy, I may also like to allow adding/deleting elements. It's not hard to develop a web page for this particular XML. My question is whether there is a general way, i.e., one that works for most XML documents. Of couse, we still need to design the html page, but can one do the following (assuming the two-step process: display, then submit an update):
- In the html page, name the <input> fields in a consistent way, e.g., using Xpath, or simply "0:2:1@name" (0th child of the root, 2nd child of that one, and 1st of its children, and the "name" attribute), etc.
- For display, the script will load the document, and extract the correct values, this seems to be easier if using xpath for the first part.
- For updates, the script will take the input parametes, change the corresponding elements/attributes (XQuery is supposed to provide a language for doing this kind of updates, sort of like SQL for updating database, there is something called XUpdate implemented in java that provides something simpler)
I've implemented something like this in java, but not complete, where I used XSLT for displaying (but the name is hard coded), and another xslt to generate xupdate instructions, works ok, but not general enough for my current task. Are there such things in perl? Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.