I have been using TagSoup for some time for various tasks and it does a great
job. One application uses TagSoup to parse HTML from the clipboard. Recently
when I recently tried to fix up my access to the SAX2DOM class I ran into
trouble. I had been using the internal implementation from the Sun JRE found in
com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM without really paying
attention that I was doing this. When I noticed I was using an internal class
that was not public I downloaded Apache Xalan 2.7.1 and tired to use it instead.
This generated the error:
java.lang.IncompatibleClassChangeError: Class
org.apache.xalan.xsltc.trax.SAX2DOM does not implement the requested interface
org.xml.sax.ContentHandler
at org.ccil.cowan.tagsoup.Parser.parse(Parser.java:405)
at
com.lesliesoftware.wizardsfamiliar.deck.editor.clipboard.ReadClipboard.createSlo\
tsFromHTMLTransfer(ReadClipboard.java:236)
at
com.lesliesoftware.wizardsfamiliar.deck.editor.clipboard.ReadClipboard.readConte\
nts(ReadClipboard.java:125)
at
com.lesliesoftware.wizardsfamiliar.deck.editor.clipboard.ReadClipboard.readConte\
nts(ReadClipboard.java:103)
at
com.lesliesoftware.wizardsfamiliar.deck.editor.actions.PasteAction$1.run(PasteAc\
tion.java:64)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
com.lesliesoftware.wizardsfamiliar.deck.editor.actions.PasteAction.run(PasteActi\
on.java:58)
...
Am I using incompatible versions? Do I need to modify my code to make it work?
Any suggestions or advice would be appreciated.
Ian
Here is the parsing code looks like this (the exception comes at the
parser.parse line):
private void createSlotsFromHTMLTransfer (String contents) {
StringReader inputReader = null;
try {
// Create and configure the parser
Parser parser = new Parser ();
parser.setFeature ("
http://xml.org/sax/features/namespace-prefixes",
true); //$NON-NLS-1$
// Parse the HTML
SAX2DOM sax2dom = new SAX2DOM ();
parser.setContentHandler (sax2dom);
inputReader = new StringReader (contents);
InputSource inputSource = new InputSource (inputReader);
inputSource.setEncoding ("UTF-8"); //$NON-NLS-1$
parser.parse (inputSource);
Node doc = sax2dom.getDOM ();
if (TraceUtil.isOptionEnabled (DebugOptions.CLIPBOARD_SAVEXML)) {
debug code to save the xml to disk omitted
}
resetCurrentLine ();
String topLevelParents = "/html:html/html:body"; //$NON-NLS-1$
NodeList topLevelNodes = XPathHelper.selectNodeList (doc,
topLevelParents);
for (int index = 0; index < topLevelNodes.getLength (); index++) {
Node curNode = topLevelNodes.item (index);
processContainingNode (curNode);
}
} catch (Exception exception) {
// Any exception indicates invalid data
EditorPlugin.getDefault ().getLog ().log
(DeckEditorError.clipboardFormatError (exception));
DND.error (DND.ERROR_INVALID_DATA);
mySlots = null;
} finally {
if (inputReader != null)
inputReader.close ();
}
}
--
Ian Leslie - Shareware Author (mailto:
lesliesoftware@...)
__________________________________________________________________
Ask a question on any topic and get answers from real people. Go to Yahoo!
Answers and share what you know at
http://ca.answers.yahoo.com