Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xml parser removal, fixing #273 #517

Merged
merged 31 commits into from Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b2b82f7
Removed test file that represents invalid XML, that should never succ…
qsiebers Jun 29, 2015
c5430dc
Fixed invalid XML doctype
qsiebers Jun 29, 2015
e2fbd03
Removed main method
qsiebers Jun 29, 2015
e9612be
Import cleanup
qsiebers Jun 29, 2015
4d98d7a
Upgraded ontopia-engine XML related classes to SAX2
qsiebers Jun 29, 2015
0417d0c
Fixed magic strings
qsiebers Jun 30, 2015
7913399
Fixed String compare with ==
qsiebers Jun 30, 2015
86e81cc
Upgraded ontopia-navigator to sax2
qsiebers Jun 30, 2015
ecefc40
Re-enabled testcase
qsiebers Jun 30, 2015
b3d335c
Upgraded DB2TM relation mapping to sax2
qsiebers Jun 30, 2015
eb755f4
Upgraded OSLSchemaWriter to sax2
qsiebers Jun 30, 2015
dc5ad71
Upgraded TMRAP to sax2
qsiebers Jun 30, 2015
745e484
Upgraded TMRAP AAR to sax2
qsiebers Jun 30, 2015
1e87086
Moved test actions to main source
qsiebers Aug 2, 2015
3bb1c59
Removed test annotations
qsiebers Aug 2, 2015
a14f008
Upgraded to Jena 2.13.0
qsiebers Aug 3, 2015
0971bfb
Refactored test cases to catch expected exceptions that occur with ne…
qsiebers Aug 3, 2015
b50eeb2
Disabled use of test classpath to interference of test classes in jetty
qsiebers Aug 3, 2015
a9b1ed4
Applied new PrettyPrinter methods to omnigator jsp
qsiebers Aug 3, 2015
a6355fa
Removed xerces and crimson dependencies
qsiebers Aug 4, 2015
8c14ec9
Merge branch 'master' into xml-parser-removal, applying jspc changes
qsiebers Aug 5, 2015
10fb92f
Removed dependency to jena pom, as distribution packaging fails to re…
qsiebers Aug 5, 2015
2a289e8
Excluded older version of xml-apis, as it breaks distribution
qsiebers Aug 5, 2015
46a873f
Upgraded to POI 3.12, removing the need for xml-apis exclusion as it …
qsiebers Aug 5, 2015
ecefd32
Merge branch 'master' into xml-parser-removal
qsiebers Aug 5, 2015
0617ecb
Merge branch 'master' into xml-parser-removal
qsiebers Aug 18, 2015
0261f2f
Fixed missing dependency
qsiebers Sep 1, 2015
4ded98e
Merge branch 'master' into xml-parser-removal
qsiebers May 24, 2016
b28c62e
Merge branch 'master' into xml-parser-removal
qsiebers Jun 1, 2016
a971a66
Merge branch 'master' into xml-parser-removal
qsiebers Dec 2, 2016
9e6e624
Removed check for crimson classes as it is no longer required nor pre…
qsiebers Dec 2, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -39,12 +39,11 @@
import org.slf4j.LoggerFactory;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.AttributeListImpl;
import org.xml.sax.helpers.AttributesImpl;

/**
* INTERNAL: DB2TM relation mapping definition. Container for a set of
Expand Down Expand Up @@ -545,12 +544,12 @@ protected String[] getValues(Attributes attrs, String plural, String singular) {
: getValues(attrs, plural);
}

protected void addAttribute(AttributeListImpl atts, String name, String type, String value) {
if (value != null) atts.addAttribute(name, type, value);
protected void addAttribute(AttributesImpl atts, String name, String type, String value) {
if (value != null) atts.addAttribute("", "", name, type, value);
}

protected void addAttribute(AttributeListImpl atts, String name, String type, String[] values) {
if (values != null) atts.addAttribute(name, type, StringUtils.join(values, ","));
protected void addAttribute(AttributesImpl atts, String name, String type, String[] values) {
if (values != null) atts.addAttribute("", "", name, type, StringUtils.join(values, ","));
}

// --------------------------------------------------------------------------
Expand All @@ -565,16 +564,16 @@ public void write(Writer writer, String encoding) throws SAXException {
write(new PrettyPrinter(writer, encoding));
}

protected void write(DocumentHandler dh) throws SAXException {
protected void write(ContentHandler dh) throws SAXException {

// initialize attributes
AttributeListImpl atts = new AttributeListImpl();
AttributesImpl atts = new AttributesImpl();

// <db2tm name="...">
if (name != null) addAttribute(atts, "name", "CDATA", name);

dh.startDocument();
dh.startElement("db2tm", atts);
dh.startElement("", "", "db2tm", atts);
atts.clear();

// prefixes
Expand All @@ -593,45 +592,46 @@ protected void write(DocumentHandler dh) throws SAXException {
break;
}

dh.startElement("using", atts);
dh.startElement("", "", "using", atts);
atts.clear();
dh.endElement("using");
dh.endElement("", "", "using");
}

// relations
for (Relation rel : getRelations()) {
// <relation>
addAttribute(atts, "name", "CDATA", rel.getName());
addAttribute(atts, "columns", "CDATA", rel.getColumns());
dh.startElement("relation", atts);
dh.startElement("", "", "relation", atts);
atts.clear();

outputEntities(rel, dh);

// </relation>
dh.endElement("relation");
dh.endElement("", "", "relation");
}

// </db2tm>
dh.endElement("db2tm");
dh.endElement("", "", "db2tm");
dh.endDocument();
}

protected void outputEntities(Relation rel, DocumentHandler dh) throws SAXException {
AttributeListImpl atts = new AttributeListImpl();
protected void outputEntities(Relation rel, ContentHandler dh) throws SAXException {
AttributesImpl atts = new AttributesImpl();

for (Entity entity : rel.getEntities()) {
if (entity.getEntityType() == Entity.TYPE_TOPIC) {
// <topic>
if (entity.getId() != null)
addAttribute(atts, "id", "CDATA", entity.getId());
addAttribute(atts, "type", "CDATA", entity.getAssociationType());
dh.startElement("topic", atts);
dh.startElement("", "", "topic", atts);
atts.clear();

outputFields(entity, dh);

// </topic>
dh.endElement("topic");
dh.endElement("", "", "topic");

} else if (entity.getEntityType() == Entity.TYPE_ASSOCIATION) {

Expand All @@ -641,18 +641,18 @@ protected void outputEntities(Relation rel, DocumentHandler dh) throws SAXExcept
addAttribute(atts, "type", "CDATA", entity.getAssociationType());
addAttribute(atts, "scope", "CDATA", entity.getScope());

dh.startElement("association", atts);
dh.startElement("", "", "association", atts);
atts.clear();

outputFields(entity, dh);

// </association>
dh.endElement("association");
dh.endElement("", "", "association");
}
}
}

protected void outputFields(Entity entity, DocumentHandler dh) throws SAXException {
protected void outputFields(Entity entity, ContentHandler dh) throws SAXException {
for (Field field : entity.getIdentityFields()) {
outputField(field, dh);
}
Expand All @@ -664,73 +664,73 @@ protected void outputFields(Entity entity, DocumentHandler dh) throws SAXExcepti
}
}

protected void outputField(Field field, DocumentHandler dh) throws SAXException {
AttributeListImpl atts = new AttributeListImpl();
protected void outputField(Field field, ContentHandler dh) throws SAXException {
AttributesImpl atts = new AttributesImpl();
if (field.getFieldType() == Field.TYPE_SUBJECT_LOCATOR) {
addAttribute(atts, "column", "CDATA", field.getColumn());
dh.startElement("subject-locator", atts);
dh.startElement("", "", "subject-locator", atts);
char[] c = field.getPattern().toCharArray();
dh.characters(c, 0, c.length);
dh.endElement("subject-locator");
dh.endElement("", "", "subject-locator");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_SUBJECT_IDENTIFIER) {
addAttribute(atts, "column", "CDATA", field.getColumn());
dh.startElement("subject-identifier", atts);
dh.startElement("", "", "subject-identifier", atts);
char[] c = field.getPattern().toCharArray();
dh.characters(c, 0, c.length);
dh.endElement("subject-identifier");
dh.endElement("", "", "subject-identifier");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_ITEM_IDENTIFIER) {
addAttribute(atts, "column", "CDATA", field.getColumn());
dh.startElement("item-identifier", atts);
dh.startElement("", "", "item-identifier", atts);
char[] c = field.getPattern().toCharArray();
dh.characters(c, 0, c.length);
dh.endElement("item-identifier");
dh.endElement("", "", "item-identifier");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_OCCURRENCE) {
addAttribute(atts, "column", "CDATA", field.getColumn());
addAttribute(atts, "type", "CDATA", field.getType());
addAttribute(atts, "scope", "CDATA", field.getScope());
addAttribute(atts, "datatype", "CDATA", field.getDatatype());
dh.startElement("occurrence", atts);
dh.endElement("occurrence");
dh.startElement("", "", "occurrence", atts);
dh.endElement("", "", "occurrence");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_TOPIC_NAME) {
addAttribute(atts, "column", "CDATA", field.getColumn());
addAttribute(atts, "type", "CDATA", field.getType());
addAttribute(atts, "scope", "CDATA", field.getScope());
dh.startElement("topic-name", atts);
dh.endElement("topic-name");
dh.startElement("", "", "topic-name", atts);
dh.endElement("", "", "topic-name");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_PLAYER) {
addAttribute(atts, "rtype", "CDATA", field.getRoleType());
addAttribute(atts, "atype", "CDATA", field.getAssociationType());
addAttribute(atts, "scope", "CDATA", field.getScope());

dh.startElement("player", atts);
dh.startElement("", "", "player", atts);
atts.clear();

for (Field orole : field.getOtherRoleFields()) {
addAttribute(atts, "rtype", "CDATA", orole.getRoleType());
addAttribute(atts, "player", "CDATA", orole.getPlayer());
dh.startElement("other", atts);
dh.endElement("other");
dh.startElement("", "", "other", atts);
dh.endElement("", "", "other");
atts.clear();
}

dh.endElement("player");
dh.endElement("", "", "player");
atts.clear();
}
else if (field.getFieldType() == Field.TYPE_ASSOCIATION_ROLE) {
addAttribute(atts, "type", "CDATA", field.getRoleType());
addAttribute(atts, "player", "CDATA", field.getPlayer());
dh.startElement("role", atts);
dh.endElement("role");
dh.startElement("", "", "role", atts);
dh.endElement("", "", "role");
atts.clear();
}
else throw new OntopiaRuntimeException("Unknown field type: " + field.getType());
Expand Down
8 changes: 0 additions & 8 deletions ontopia-engine/pom.xml
Expand Up @@ -71,14 +71,6 @@
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
</dependency>
<dependency>
<groupId>crimson</groupId>
<artifactId>crimson</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
1 change: 0 additions & 1 deletion ontopia-engine/src/main/java/net/ontopia/Ontopia.java
Expand Up @@ -216,7 +216,6 @@ private static void checkProduct() {
*/
public static void checkClasses() {
checkClass("net.ontopia.topicmaps.core.TopicMapIF", "ontopia.jar");
checkClass("org.apache.crimson.jaxp.SAXParserFactoryImpl", "crimson.jar");
checkClass("org.slf4j.Logger", "slf4j-api.jar");
checkClass("org.apache.commons.collections4.map.LRUMap", "commons-collections4.jar");
checkClass("gnu.getopt.Getopt", "getopt.jar");
Expand Down