Ignore:
Timestamp:
2003-01-24T15:54:55+13:00 (21 years ago)
Author:
kjdon
Message:

updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/docs/manual/hints.tex

    r3557 r3707  
    1313\maketitle
    1414
     15\section{Java code}
     16
     17the java code is found in gsdl3/src/java/org/greenstone/gsdl3
     18util has various utility classes, service has the services, action has the actions, build has the building code, etc.
     19
    1520\section{Working with XML}
    1621
    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.
     22We 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
     24There is a utility class called XMLConverter - this creates new Documents, and converts Strings or files to Documents.
     25eg:
     26XMLConverter converter = new XMLConverter();
     27Document doc = converter.newDOM();
     28
     29File stylesheet = new File(``query.xsl'');
     30Document style = converter.getDOM(stylesheet);
     31
     32String message = ``<message><request type='cgi'/></message>'';
     33Document m = converter.getDOM(message);
     34
     35To output a document as a String, use converter.getString(doc);
     36
     37
     38To add nodes and stuff to an empty document - create them, then append to the tree
     39
     40Document doc = converter.newDOM();
     41Element e = doc.createElement(``message'');
     42doc.appendChild(e);
     43
     44Note, 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.
    1845
    1946\section{Working with XSLT}
Note: See TracChangeset for help on using the changeset viewer.