Changeset 3707 for trunk/gsdl3/docs/manual
- Timestamp:
- 2003-01-24T15:54:55+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/docs/manual/hints.tex
r3557 r3707 13 13 \maketitle 14 14 15 \section{Java code} 16 17 the java code is found in gsdl3/src/java/org/greenstone/gsdl3 18 util has various utility classes, service has the services, action has the actions, build has the building code, etc. 19 15 20 \section{Working with XML} 16 21 17 We use the DOM model for handling XML. This involves Documents, Nodes, Elements etc. Node is the basic thing in the tree, all others inherit from this. A Document represents a whole document, and is a kind of container for all the nodes. Elements and Nodes are not supposed to exist outside of the context of a document, so you have to have a document to create them. The document is not the top level node in the tree, to get this, use Document.getDocumentElement(). If you create nodes etc but dont append them to something already n the document tree, they will be separate - but they still know who their owner document is. 22 We use the DOM model for handling XML. This involves Documents, Nodes, Elements etc. Node is the basic thing in the tree, all others inherit from this. A Document represents a whole document, and is a kind of container for all the nodes. Elements and Nodes are not supposed to exist outside of the context of a document, so you have to have a document to create them. The document is not the top level node in the tree, to get this, use Document.getDocumentElement(). If you create nodes etc but dont append them to something already in the document tree, they will be separate - but they still know who their owner document is. 23 24 There is a utility class called XMLConverter - this creates new Documents, and converts Strings or files to Documents. 25 eg: 26 XMLConverter converter = new XMLConverter(); 27 Document doc = converter.newDOM(); 28 29 File stylesheet = new File(``query.xsl''); 30 Document style = converter.getDOM(stylesheet); 31 32 String message = ``<message><request type='cgi'/></message>''; 33 Document m = converter.getDOM(message); 34 35 To output a document as a String, use converter.getString(doc); 36 37 38 To add nodes and stuff to an empty document - create them, then append to the tree 39 40 Document doc = converter.newDOM(); 41 Element e = doc.createElement(``message''); 42 doc.appendChild(e); 43 44 Note, you can only append one node to a document - this will become the toplevel node. After that, you can append nodes to child nodes as you like, but a document is only allowed one top level node. 18 45 19 46 \section{Working with XSLT}
Note:
See TracChangeset
for help on using the changeset viewer.