1 | \documentclass[a4paper,11pt]{article}
|
---|
2 | \usepackage{times,epsfig}
|
---|
3 |
|
---|
4 | \newenvironment{bulletedlist}%
|
---|
5 | {\begin{list}{$\bullet$}{\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}}}%
|
---|
6 | {\end{list}}
|
---|
7 |
|
---|
8 |
|
---|
9 | \begin{document}
|
---|
10 |
|
---|
11 | \title{Some hints for developers}
|
---|
12 |
|
---|
13 | \maketitle
|
---|
14 |
|
---|
15 | \section{Working with XML}
|
---|
16 |
|
---|
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.
|
---|
18 |
|
---|
19 | \section{Working with XSLT}
|
---|
20 |
|
---|
21 | * adding html to an xml doc:
|
---|
22 |
|
---|
23 | eg I have a text node with html inside it inside a resource element
|
---|
24 | to add that to a new XML doc, I use
|
---|
25 | {\em <xsl:value-of select='resource'>\/}
|
---|
26 |
|
---|
27 | if the output mode is xml or html, this will escape any special characters
|
---|
28 | ie $<$ and $>$ etc
|
---|
29 |
|
---|
30 | use
|
---|
31 | {\em <xsl:value-of disable-output-escaping="yes" select='resource'>\/}
|
---|
32 | instead.
|
---|
33 |
|
---|
34 | * including an xml doc into a stylesheet:
|
---|
35 |
|
---|
36 | {\em <xsl:variable name='import' select='document(``newdoc.xml'')'/>\/}
|
---|
37 |
|
---|
38 | then can use the info:
|
---|
39 |
|
---|
40 | {\em <xsl:value-of select='\$import/element'/>\/}
|
---|
41 |
|
---|
42 | * selecting an ancestor:
|
---|
43 |
|
---|
44 | the ancestor axis contains the parent of the context node, and its
|
---|
45 | parent and so on. to pick one node among these:
|
---|
46 | ancestor::elem-name. I dont know how this works if there are two
|
---|
47 | nodes with the same name in the axis.
|
---|
48 |
|
---|
49 | * basic XSLT elements
|
---|
50 | \begin{quote}\begin{footnotesize}\begin{verbatim}
|
---|
51 | <xsl:template match='xxx' name='yyy'/>
|
---|
52 |
|
---|
53 | <xsl:apply-templates select='xxx'/>
|
---|
54 | <xsl:call-templates name='yyy'/>
|
---|
55 |
|
---|
56 | <xsl:variable name='doc' select='document("layout.xml")'/>
|
---|
57 |
|
---|
58 | <xsl:value-of select='$doc/chapter1'/> $
|
---|
59 | \end{verbatim}\end{footnotesize}\end{quote}
|
---|
60 |
|
---|
61 | \subsection{What can I do to speed up XSL transformations?}
|
---|
62 |
|
---|
63 | This information taken from the Xalan FAQS page.
|
---|
64 |
|
---|
65 | \begin{bulletedlist}
|
---|
66 |
|
---|
67 | \item Use a Templates object (with a different Transformers for each
|
---|
68 | transformation) to perform multiple transformations with the same set
|
---|
69 | of stylesheet instructions (see Multithreading).
|
---|
70 |
|
---|
71 | \item Set up your stylesheets to function efficiently.
|
---|
72 |
|
---|
73 | \item Don't use "//" (descendant axes) patterns near the root of a
|
---|
74 | large document.
|
---|
75 |
|
---|
76 | \item Use xsl:key elements and the key() function as an efficient way
|
---|
77 | to retrieve node sets.
|
---|
78 |
|
---|
79 | \item Where possible, use pattern matching rather than xsl:if or
|
---|
80 | xsl:when statements.
|
---|
81 |
|
---|
82 | \item xsl:for-each is fast because it does not require pattern matching.
|
---|
83 |
|
---|
84 | \item Keep in mind that xsl:sort prevents incremental processing.
|
---|
85 |
|
---|
86 | \item When you create variables,
|
---|
87 | {\em <xsl:variable name="fooElem" select="foo"/>\/} is usually faster
|
---|
88 | than \\
|
---|
89 | {\em <xsl:variable name="fooElem"><xsl:value-of-select="foo"/></xsl:variable>\/}.
|
---|
90 |
|
---|
91 | \item Be careful using the last() function.
|
---|
92 |
|
---|
93 | \item The use of index predicates within match patterns can be expensive.
|
---|
94 |
|
---|
95 | \item Decoding and encoding is expensive.
|
---|
96 |
|
---|
97 | \item For the ultimate in server-side scalability, perform transform
|
---|
98 | operations on the client. For examples, see appletXMLtoHTML and
|
---|
99 | get-todo-list.
|
---|
100 |
|
---|
101 | \end{bulletedlist}
|
---|
102 |
|
---|
103 | \section{Java gdbm}
|
---|
104 |
|
---|
105 | To talk to gdbm, a jni wrapper called java-gdbm is used. It was
|
---|
106 | obtained from:\\ {\tt
|
---|
107 | http://aurora.rg.iupui.edu/~schadow/dbm-java/pip/gdbm/}
|
---|
108 |
|
---|
109 | It uses packing objects to convert to and from an array of bytes (in
|
---|
110 | gdbm file) from and to java objects. In my GDBMWrapper class I use
|
---|
111 | StringPacking - uese UTF-8 encoding. but some stuff came out funny. so
|
---|
112 | I had to changes the from\_bytes method in StringPacking.java to use
|
---|
113 | new String(raw, "UTF-8") instead of new String(raw). this seems to
|
---|
114 | work.
|
---|
115 |
|
---|
116 | Note---if we use this gdbm stuff to create the file too, may need to
|
---|
117 | alter the to-bytes method.
|
---|
118 |
|
---|
119 | The makefile in j-gdbm is crap---it tries to get stuff from its
|
---|
120 | original CVS tree. I have created a new Makefile---in my-j-gdbm
|
---|
121 | directory. this stuff needs to go into cvs probably.
|
---|
122 |
|
---|
123 | * I dont think {\em <xsl:with-param name='xxx' select='true'/>\/} is
|
---|
124 | the same as {\em <xsl:with-param name='xxx'>true</xsl:with-param>\/}
|
---|
125 | use the second one.
|
---|
126 |
|
---|
127 |
|
---|
128 | \section{Resources}
|
---|
129 |
|
---|
130 | Contents for 'The Java Native Interface Programmer's Guide and
|
---|
131 | Specification' on-line\\ {\tt
|
---|
132 | http://java.sun.com/docs/books/jni/html/jniTOC.html}
|
---|
133 |
|
---|
134 | Java Native Interface Specification\\
|
---|
135 | {\tt http://java.sun.com/j2se/1.4/docs/guide/jni/spec/jniTOC.doc.html}
|
---|
136 |
|
---|
137 | JNI Documentation Contents\\
|
---|
138 | {\tt http://java.sun.com/j2se/1.4/docs/guide/jni/index.html}
|
---|
139 |
|
---|
140 | another JNI page\\
|
---|
141 | {\tt http://mindprod.com/jni.html}
|
---|
142 |
|
---|
143 | Java 1.4 api index\\
|
---|
144 | {\tt http://java.sun.com/j2se/1.4/docs/api/index.html}
|
---|
145 |
|
---|
146 | Java tutorial index\\
|
---|
147 | {\tt http://java.sun.com/docs/books/tutorial/index.html}
|
---|
148 |
|
---|
149 | Safari books online - has java, XML, XSLT, etc books\\
|
---|
150 | {\tt http://proquest.safaribooksonline.com/mainhom.asp?home}
|
---|
151 |
|
---|
152 | Java 1.4 i18n FAQ\\
|
---|
153 | {\tt http://www.sun.com/developers/gadc/faq/java/java1.4.html}
|
---|
154 |
|
---|
155 | Java and XSLT page\\
|
---|
156 | {\tt http://www.javaolympus.com/java/Java\%20and\%20XSLT.html}
|
---|
157 |
|
---|
158 | Xalan-Java overview\\
|
---|
159 | {\tt http://xml.apache.org/xalan-j/overview.html}
|
---|
160 |
|
---|
161 | Tomcat documentation index\\
|
---|
162 | {\tt http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html}
|
---|
163 |
|
---|
164 | Servlet and JSP tutorial\\
|
---|
165 | {\em http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/\/}
|
---|
166 |
|
---|
167 | Core Servlets and JavaServer Pages, book by Marty Hall. download the
|
---|
168 | pdf from here (try before you buy link)\\ {\tt
|
---|
169 | http://www.coreservlets.com/}
|
---|
170 |
|
---|
171 | J-gdbm page\\
|
---|
172 | {\em http://aurora.rg.iupui.edu/~schadow/dbm-java/pip/gdbm/\/}
|
---|
173 |
|
---|
174 | Stuarts page of links\\
|
---|
175 | {\em http://www.cs.waikato.ac.nz/~nzdl/gsdl3/\/}
|
---|
176 |
|
---|
177 | a good basic xslt tutorial\\
|
---|
178 | {\tt http://www.zvon.org/xxl/XSLTutorial/Books/Output/contents.html}
|
---|
179 |
|
---|
180 | JAXP (java api for xml processing) package overview\\
|
---|
181 | {\tt http://java.sun.com/xml/jaxp/dist/1.1/docs/api/overview-summary.html}
|
---|
182 |
|
---|
183 | DeveloperWorks, xml zone\\
|
---|
184 | {\tt http://www-106.ibm.com/developerworks/xml/}
|
---|
185 |
|
---|
186 | xslt.com\\
|
---|
187 | {\tt http://www.xslt.com/}
|
---|
188 |
|
---|
189 | jeni tennison's xslt pages\\
|
---|
190 | {\tt http://www.jenitennison.com/xslt/}
|
---|
191 |
|
---|
192 | apaches xml tools\\
|
---|
193 | {\tt http://xml.apache.org/}
|
---|
194 |
|
---|
195 |
|
---|
196 | \end{document}
|
---|