1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
---|
2 | |
---|
3 | <html> |
---|
4 | |
---|
5 | <head> |
---|
6 | <title>J User's Guide - XML Mode</title> |
---|
7 | <LINK REL="stylesheet" HREF="j.css" TYPE="text/css"> |
---|
8 | </head> |
---|
9 | |
---|
10 | <body> |
---|
11 | |
---|
12 | <a href="contents.html">Top</a> |
---|
13 | |
---|
14 | <hr> |
---|
15 | |
---|
16 | <h1>XML Mode</h1> |
---|
17 | |
---|
18 | <hr> |
---|
19 | |
---|
20 | <p> |
---|
21 | In XML mode, the bottom pane of the sidebar normally displays a tree |
---|
22 | representing the document you're editing. The tree is enabled by default. To |
---|
23 | disable it, add the following line to your |
---|
24 | <a href="preferences.html">preferences</a> file: |
---|
25 | <pre> |
---|
26 | XmlMode.enableTree = false |
---|
27 | </pre> |
---|
28 | <p> |
---|
29 | If the tree is enabled but no tree appears in the sidebar, the most likely |
---|
30 | reason is that j's XML parser was unable to parse the contents of the buffer. |
---|
31 | Parsing is done in a background thread, so it may take a little while for the |
---|
32 | tree to appear (or possibly a long while, if the document references a DTD on |
---|
33 | the Internet, for example). |
---|
34 | <p> |
---|
35 | Starting with version 0.19.0.2, j uses the XML parser provided as part of the |
---|
36 | Java 1.4 runtime library. (Earlier versions of j included a version of the |
---|
37 | Ælfred XML parser.) |
---|
38 | <p> |
---|
39 | If you would rather use a different XML parser, you need to do two things: |
---|
40 | <ul> |
---|
41 | <li> |
---|
42 | Add the relevant jar file(s) to j's runtime <code>CLASSPATH</code>. If you |
---|
43 | build j from source, you can use the configure script's |
---|
44 | <code>--with-extensions</code> option to do this: |
---|
45 | <pre> |
---|
46 | ./configure --with-extensions=/usr/share/java/xercesImpl.jar |
---|
47 | </pre> |
---|
48 | The j shell script that is automatically generated and installed will then use |
---|
49 | the correct <code>CLASSPATH</code>. |
---|
50 | <br><br> |
---|
51 | </li> |
---|
52 | <li> |
---|
53 | Add a line to your <a href="preferences.html">preferences</a> file to specify |
---|
54 | the <a href="preferences.html#org.xml.sax.driver">org.xml.sax.driver</a> |
---|
55 | property, which tells j the fully qualified class name of the parser to use. |
---|
56 | For example: |
---|
57 | <pre> |
---|
58 | org.xml.sax.driver = org.apache.xerces.parsers.SAXParser |
---|
59 | </pre> |
---|
60 | (The corresponding property in versions of j prior to 0.19.0.2 was |
---|
61 | "org.xml.sax.parser".) |
---|
62 | </li> |
---|
63 | </ul> |
---|
64 | <p> |
---|
65 | When you have a tree in the sidebar, the selection in the tree will follow |
---|
66 | along as you navigate in the edit buffer, but the tree is not automatically |
---|
67 | expanded to show nested nodes. You can use |
---|
68 | <a href="commands.html#xmlFindCurrentNode">xmlFindCurrentNode</a>, mapped by |
---|
69 | default to Ctrl =, to force the tree to expand all the way down to the node |
---|
70 | corresponding to the location of the caret in the edit buffer. |
---|
71 | <p> |
---|
72 | Clicking on a node in the tree moves the caret to the corresponding |
---|
73 | location in the edit buffer. |
---|
74 | <p> |
---|
75 | The tree is refreshed automatically by the idle thread when you make changes to |
---|
76 | the buffer. |
---|
77 | <p> |
---|
78 | You can also use <a href="commands.html#xmlParseBuffer">xmlParseBuffer</a>, |
---|
79 | mapped by default to Ctrl P, to force the tree to be refreshed. The parser uses |
---|
80 | the image of the buffer in memory, rather than the file on disk, so there's no |
---|
81 | need to save any changes you've made to the buffer before refreshing the tree. |
---|
82 | <p> |
---|
83 | If <a href="commands.html#xmlParseBuffer">xmlParseBuffer</a> encounters an |
---|
84 | error, the tree is not updated. |
---|
85 | <p> |
---|
86 | Parser errors that occur when j is automatically refreshing the tree are not reported. |
---|
87 | <p> |
---|
88 | <a href="commands.html#xmlParseBuffer">xmlParseBuffer</a> invokes |
---|
89 | <a href="commands.html#xmlFindCurrentNode">xmlFindCurrentNode</a> automatically |
---|
90 | when it succeeds in updating the tree. |
---|
91 | <p> |
---|
92 | The following commands are also specifically relevant in XML mode: |
---|
93 | <ul> |
---|
94 | <li><a href="commands.html#xmlElectricEquals">xmlElectricEquals</a></li> |
---|
95 | <li><a href="commands.html#xmlFindMatch">xmlFindMatch</a></li> |
---|
96 | <li><a href="commands.html#xmlInsertEmptyElementTag">xmlInsertEmptyElementTag</a></li> |
---|
97 | <li><a href="commands.html#xmlInsertTag">xmlInsertTag</a></li> |
---|
98 | <li><a href="commands.html#xmlValidateBuffer">xmlValidateBuffer</a></li> |
---|
99 | </ul> |
---|
100 | </body> |
---|
101 | </html> |
---|