Date: 2004-09-15T21:12:33 Editor: TonyEdwards <[EMAIL PROTECTED]> Wiki: Cocoon Wiki Page: FlowBasedXMLEditor URL: http://wiki.apache.org/cocoon/FlowBasedXMLEditor
no comment Change Log: ------------------------------------------------------------------------------ @@ -24,13 +24,14 @@ [[BR]]Utilising actions extensively it became a bit of a maintenance nightmare. It basically allowed the user to create, edit and render into different formats an xml document derived from a proprietory namespace. One of my greatest reservations about this method was the heavy emphasis on Java as I'm not much of a java programmer at all. [[BR]]When 2.1.4 came along I thought I'd port the application and jazz it up at the same time. I managed to scrape up enough examples and snippets to come up with a fairly usable solution. [[BR]]Using flow to manipulate xml proved to be pretty straight forward, although I'm not too sure as to the efficiency and optimisability of its application. [[BR]]So far so good though. -[[BR]] First step was to create a new flowscript file and include the necessary XML manipulation classes. I'm generally flying blind when it comes to importing all these classes so there may be some redundancy. +[[BR]] First step was to create a new flowscript file and include the necessary XML manipulation classes. I'm generally flying blind when it comes to importing all these classes so there may be some redundancy. [[BR]]importClass(org.apache.xpath.XPathAPI); [[BR]]importClass(javax.xml.parsers.DocumentBuilderFactory); [[BR]]importClass(org.w3c.dom.Node); [[BR]]importClass(org.w3c.dom.Element); [[BR]]importClass(org.w3c.dom.NodeList); -[[BR]] Thereafter is became an exercise in wrapping the DOM functions in flow script. Attached is my general purpose jsUtils.js file which contains all the necessary methods to carry out DOM manipulation. If anyone can see any obvious flaws, please let me know! +[[BR]] Thereafter is became an exercise in wrapping the DOM functions in flow script. +[[BR]]Attached to this page should be my general purpose '''jsUtils.js''' file which contains all the necessary methods to carry out DOM manipulation. If anyone can see any obvious flaws, please let me know! To create a new document, pass the name of the document to the '''newDocument''' function. Adding attributes is as simple as calling '''addAttribute'''. If the nodeParent parameter is null, the attribute gets assigned to the document root. [[BR]]The use of the '''sessionManager''' is interesting. [[BR]]I couldn't for the life of me get a reference to the DOM if I used the '''cocoon.session''' object. I don't know why. I scoured all manner of places and found the use of the sessionManager, stuck the document in there, and then I was able to access the DOM from the pipeline. Maybe I missed something, but it works.
