Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SAX XML fixes
  • Loading branch information
hansonr hansonr
hansonr authored and hansonr committed Aug 21, 2018
commit dd35a50cf7c14d85dc7c0c41dbfe5366cb057302
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
6 changes: 1 addition & 5 deletions sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
20180820200147
=======
20180820101854
>>>>>>> branch 'yadav1' of https://github.com/BobHanson/java2script.git
20180820232825
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/SwingJS-site.zip
Binary file not shown.
6 changes: 1 addition & 5 deletions sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/timestamp
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
20180820200147
=======
20180820101854
>>>>>>> branch 'yadav1' of https://github.com/BobHanson/java2script.git
20180820232825
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public SAXParser newSAXParser() {
for (Object name : props.keySet()) {
r.setProperty((String) name, props.getProperty((String)name));
}
} else if (p instanceof org.xml.sax.XMLReader) {
org.xml.sax.XMLReader r = (org.xml.sax.XMLReader) p;
for (Object name : props.keySet()) {
r.setProperty((String) name, props.getProperty((String)name));
}
}
return p;
} catch (Exception e) {
Expand Down
34 changes: 28 additions & 6 deletions sources/net.sf.j2s.java.core/src/swingjs/JSSAXParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

@SuppressWarnings({"deprecation"})
public class JSSAXParser implements Parser, XMLReader {
Expand Down Expand Up @@ -62,7 +63,7 @@ public void setErrorHandler(ErrorHandler handler) {
this.errorHandler = handler;
}

public void parse(InputSource source, JSSAXContentHandler handler) throws SAXException, IOException {
public void parse(InputSource source, DefaultHandler handler) throws SAXException, IOException {
setContentHandler(handler);
parseSource(source);
}
Expand Down Expand Up @@ -122,12 +123,12 @@ private DOMNode parseXML(String data) {
* @return reconfigured data
*/
private String removeProcessing(String data) {
if (data.indexOf("<?") >= 0) {
if (false && data.indexOf("<?") >= 0) { // doesn't seem to be necessary?
getUniqueSequence(data);
data = PT.rep(PT.rep(data, "<?", "<![CDATA[" + uniqueSeq), "?>", "]]>");
if (data.startsWith("<!")) {
data = "<pre>" + data + "</pre>";
havePre = true;
data = "<pre>" + data + "</pre>";
havePre = true;
}
}
return data;
Expand All @@ -153,8 +154,10 @@ private void error(Exception e) throws SAXException {
private boolean ver2;


private static final int ELEMENT_TYPE = 1;

/**
* early Jmol method allowing reading data from an XHTML document
* Using JQuery to reading data from an XHTML document
*
* @param doc
* @throws SAXException
Expand All @@ -167,7 +170,26 @@ private void parseDocument(DOMNode doc) throws SAXException {
contentHandler.startDocument();
else
docHandler.startDocument();
walkDOMTree((DOMNode) DOMNode.getAttr(doc, "firstChild"), havePre);

// We must continue down until we have the root node.

DOMNode element = (DOMNode) DOMNode.getAttr(doc, "firstChild");

// skipping type 8 (processing directive) and type 10 (doctype) and anything
// that is not 1 (element)

/**
* @j2sNative
*
* var type;
* while (element && (type = element.nodeType) != 1) {
* element = element.nextSibling;
* }
*
*/


walkDOMTree(element, havePre);
if (ver2)
contentHandler.endDocument();
else
Expand Down