source: trunk/gsdl3/docs/manual/hints.tex@ 3557

Last change on this file since 3557 was 3557, checked in by kjdon, 21 years ago

added docs to cvs

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
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
17We 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
23eg I have a text node with html inside it inside a resource element
24to add that to a new XML doc, I use
25{\em <xsl:value-of select='resource'>\/}
26
27if the output mode is xml or html, this will escape any special characters
28ie $<$ and $>$ etc
29
30use
31{\em <xsl:value-of disable-output-escaping="yes" select='resource'>\/}
32instead.
33
34* including an xml doc into a stylesheet:
35
36{\em <xsl:variable name='import' select='document(``newdoc.xml'')'/>\/}
37
38then 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
63This information taken from the Xalan FAQS page.
64
65\begin{bulletedlist}
66
67\item Use a Templates object (with a different Transformers for each
68transformation) to perform multiple transformations with the same set
69of 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
74large document.
75
76\item Use xsl:key elements and the key() function as an efficient way
77to retrieve node sets.
78
79\item Where possible, use pattern matching rather than xsl:if or
80xsl: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
88than \\
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
98operations on the client. For examples, see appletXMLtoHTML and
99get-todo-list.
100
101\end{bulletedlist}
102
103\section{Java gdbm}
104
105To talk to gdbm, a jni wrapper called java-gdbm is used. It was
106obtained from:\\ {\tt
107http://aurora.rg.iupui.edu/~schadow/dbm-java/pip/gdbm/}
108
109It uses packing objects to convert to and from an array of bytes (in
110gdbm file) from and to java objects. In my GDBMWrapper class I use
111StringPacking - uese UTF-8 encoding. but some stuff came out funny. so
112I had to changes the from\_bytes method in StringPacking.java to use
113new String(raw, "UTF-8") instead of new String(raw). this seems to
114work.
115
116Note---if we use this gdbm stuff to create the file too, may need to
117alter the to-bytes method.
118
119The makefile in j-gdbm is crap---it tries to get stuff from its
120original CVS tree. I have created a new Makefile---in my-j-gdbm
121directory. this stuff needs to go into cvs probably.
122
123* I dont think {\em <xsl:with-param name='xxx' select='true'/>\/} is
124the same as {\em <xsl:with-param name='xxx'>true</xsl:with-param>\/}
125use the second one.
126
127
128\section{Resources}
129
130Contents for 'The Java Native Interface Programmer's Guide and
131Specification' on-line\\ {\tt
132http://java.sun.com/docs/books/jni/html/jniTOC.html}
133
134Java Native Interface Specification\\
135{\tt http://java.sun.com/j2se/1.4/docs/guide/jni/spec/jniTOC.doc.html}
136
137JNI Documentation Contents\\
138{\tt http://java.sun.com/j2se/1.4/docs/guide/jni/index.html}
139
140another JNI page\\
141{\tt http://mindprod.com/jni.html}
142
143Java 1.4 api index\\
144{\tt http://java.sun.com/j2se/1.4/docs/api/index.html}
145
146Java tutorial index\\
147{\tt http://java.sun.com/docs/books/tutorial/index.html}
148
149Safari books online - has java, XML, XSLT, etc books\\
150{\tt http://proquest.safaribooksonline.com/mainhom.asp?home}
151
152Java 1.4 i18n FAQ\\
153{\tt http://www.sun.com/developers/gadc/faq/java/java1.4.html}
154
155Java and XSLT page\\
156{\tt http://www.javaolympus.com/java/Java\%20and\%20XSLT.html}
157
158Xalan-Java overview\\
159{\tt http://xml.apache.org/xalan-j/overview.html}
160
161Tomcat documentation index\\
162{\tt http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html}
163
164Servlet and JSP tutorial\\
165{\em http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/\/}
166
167Core Servlets and JavaServer Pages, book by Marty Hall. download the
168pdf from here (try before you buy link)\\ {\tt
169http://www.coreservlets.com/}
170
171J-gdbm page\\
172{\em http://aurora.rg.iupui.edu/~schadow/dbm-java/pip/gdbm/\/}
173
174Stuarts page of links\\
175{\em http://www.cs.waikato.ac.nz/~nzdl/gsdl3/\/}
176
177a good basic xslt tutorial\\
178{\tt http://www.zvon.org/xxl/XSLTutorial/Books/Output/contents.html}
179
180JAXP (java api for xml processing) package overview\\
181{\tt http://java.sun.com/xml/jaxp/dist/1.1/docs/api/overview-summary.html}
182
183DeveloperWorks, xml zone\\
184{\tt http://www-106.ibm.com/developerworks/xml/}
185
186xslt.com\\
187{\tt http://www.xslt.com/}
188
189jeni tennison's xslt pages\\
190{\tt http://www.jenitennison.com/xslt/}
191
192apaches xml tools\\
193{\tt http://xml.apache.org/}
194
195
196\end{document}
Note: See TracBrowser for help on using the repository browser.