Search the web
Sign In
New User? Sign Up
tagsoup-friends · Friends of TagSoup
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Switching from internal SAX2DOM to SAX2DOM from Apache causes Incomp   Message List  
Reply | Forward Message #1286 of 1386 |

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



Fri May 29, 2009 10:39 am

lesliesoftware
Offline Offline
Send Email Send Email

Forward
Message #1286 of 1386 |
Expand Messages Author Sort by Date

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...
Leslie Software
lesliesoftware
Offline Send Email
May 29, 2009
10:41 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help