<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">In JDOM 2.x the new SAXBuilder() (no
arguments) will use regular JAXP API's to get the right SAX Parser
for your system.<br>
<br>
The JAXP process is described here:
<a class="moz-txt-link-freetext" href="http://docs.oracle.com/javase/7/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance%28%29">http://docs.oracle.com/javase/7/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance%28%29</a><br>
<br>
In most cases, if you want to use a particular parser (xerces, for
example), all you need to do is add the jar to the classpath. As a
fallback mechanism, the standard JRE has an XML Parser built in
already (an older version of xerces with some customizations - one
of which is that it is not in the regular apache package.... so
you cannot call it org.apache.xerces.parsers.SAXParser). So, you
do not need to have any third-party jar unless you want one. I
would still recommend adding xerces to your classpath though (and
with it, you will want the xml-apis.jar).<br>
<br>
So, in your 'old' code, if you used to do:<br>
<br>
... = new SAXBuilder("org.apache.xerces.parsers.SAXParser");<br>
<br>
then I suggest you either:<br>
- add (only) xerces (with xmlapis.jar) to the classpath, and
use the plain ... = new SAXBuilder(); constructor....<br>
- add xerces to the classpath, use ... = new SAXBuilder(new
XMLReaderSAX2Factory(false,
"org.apache.xerces.parsers.SAXParser"));<br>
<br>
Note though, that the deprecated/'old' constructor new
SAXBuilder("org.apache.xerces.parsers.SAXParser"); will still work
(with a deprecated warning) if you have the xerces.jar in your
classpath.<br>
<br>
I recommend that you use the (newer) JAXP API for constructing
SAXBuilders. You can still customize it with a particular library.<br>
<br>
I note that there is a lack of functionality in JDOM for using
JAXP with a custom factory.... I will add that.... I think.... see
issue #89<br>
<br>
For what it's worth, the documentation on the org.jdom.input.sax
is fairly comprehensive:
<a class="moz-txt-link-freetext" href="http://www.jdom.org/docs/apidocs/org/jdom2/input/sax/package-summary.html">http://www.jdom.org/docs/apidocs/org/jdom2/input/sax/package-summary.html</a>
even though it does not have an example of what you want (although
it has other examples).<br>
<br>
Also, the source code for the deprecated constructor is
educational... :<br>
<a class="moz-txt-link-freetext" href="https://github.com/hunterhacker/jdom/blob/master/core/src/java/org/jdom2/input/SAXBuilder.java#L266">https://github.com/hunterhacker/jdom/blob/master/core/src/java/org/jdom2/input/SAXBuilder.java#L266</a><br>
and<br>
<a class="moz-txt-link-freetext" href="https://github.com/hunterhacker/jdom/blob/master/core/src/java/org/jdom2/input/SAXBuilder.java#L288">https://github.com/hunterhacker/jdom/blob/master/core/src/java/org/jdom2/input/SAXBuilder.java#L288</a><br>
<br>
I will consider the usage of a JAXP custom factory using the
'other' JAXP constructor:
<a class="moz-txt-link-freetext" href="http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance%28java.lang.String,%20java.lang.ClassLoader%29">http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance%28java.lang.String,%20java.lang.ClassLoader%29</a><br>
<br>
Issue #89: <a class="moz-txt-link-freetext" href="https://github.com/hunterhacker/jdom/issues/89">https://github.com/hunterhacker/jdom/issues/89</a><br>
<br>
Rolf<br>
<br>
On 21/08/2012 1:23 PM, Craig Christophersen wrote:<br>
</div>
<blockquote cite="mid:000901cd7fc1$b64fc830$22ef5890$@synesis7.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hello;<o:p></o:p></p>
<p class="MsoNormal">While I now have jdom2 compiling OK in an
application, I am running into runtime problems with
SAXBuilder.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">With previous jdom both SAXBuilder builder
= new SAXBuilder(); and SAXBuilder builder = new SAXBuilder(“<u><span
style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">org.apache.xerces.parsers.SAXParser</span></u>”);<span
style="font-size:10.0pt;font-family:Consolas;color:black">
worked for constructing a SAXBuilder.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black">Question:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black">So
now to use new SAXBuilder() (which uses JAXP) do I need
something additional in my classpath?? <o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black">Or
is there somewhere I can see an example of what is mentioned
in the migration guide ---</span> <b>Deprecated.</b> <i>use
<a moz-do-not-send="true"
href="http://www.jdom.org/docs/apidocs/org/jdom2/input/SAXBuilder.html#SAXBuilder%28org.jdom2.input.sax.XMLReaderJDOMFactory%29"><code><span
style="font-size:10.0pt;color:blue">SAXBuilder(XMLReaderJDOMFactory)</span></code></a>
with <a moz-do-not-send="true"
href="http://www.jdom.org/docs/apidocs/org/jdom2/input/sax/XMLReaderSAX2Factory.html#XMLReaderSAX2Factory%28boolean,%20java.lang.String%29"><code><span
style="font-size:10.0pt;color:blue">XMLReaderSAX2Factory.XMLReaderSAX2Factory(boolean,
String)</span></code></a>?</i><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:black">Thanks,
<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Craig Christophersen<o:p></o:p></p>
<p class="MsoNormal">Software Developer<o:p></o:p></p>
<p class="MsoNormal">Synesis7<o:p></o:p></p>
<p class="MsoNormal"><a moz-do-not-send="true"
href="mailto:craigch@synesis7.com">craigch@synesis7.com</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
To control your jdom-interest membership:
<a class="moz-txt-link-freetext" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a></pre>
</blockquote>
<br>
</body>
</html>