Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Fix in schema parser
  • Loading branch information
chris1010010 committed May 29, 2019
1 parent bdc7a6c commit 5674435
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ else if (RegionType.NoiseRegion.equals(type))
else if (RegionType.SeparatorRegion.equals(type))
return "SeparatorRegionType";
else if (RegionType.TableRegion.equals(type))
return "TableeRegionType";
return "TableRegionType";
else if (RegionType.TextRegion.equals(type))
return "TextRegionType";
else if (RegionType.UnknownRegion.equals(type))
Expand Down
35 changes: 30 additions & 5 deletions java/PrimaIo/src/org/primaresearch/io/xml/DefaultSchemaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static class SchemaHandler extends DefaultHandler {

private Map<String, VariableMap> typeAttrMap = new HashMap<String, VariableMap>(); // Map [type name, attribute templates]
private Map<String, Map<String, String>> pendingSimpleType = new HashMap<String, Map<String, String>>();
private Map<String, SimpleType> simpleTypes = new HashMap<String, SimpleType>();
private Map<String, Map<String, SimpleType>> simpleTypes = new HashMap<String, Map<String, SimpleType>>(); //Map [scope, Map[name, type]]
private VariableMap currentAttributeMap = null;
private SimpleType currentSimpleType = null;
private String currentType = null;
Expand Down Expand Up @@ -174,7 +174,14 @@ else if ("simpleType".equals(localName)) {
if (pendingAttributeWithInlineType != null) {
String name = pendingAttributeWithInlineType+"Type";
currentSimpleType = new SimpleType(name);
simpleTypes.put(name, currentSimpleType);

Map<String, SimpleType> localSimpleTypes = simpleTypes.get(currentType);
if (localSimpleTypes == null)
{
localSimpleTypes = new HashMap<String,SimpleType>();
simpleTypes.put(currentType, localSimpleTypes);
}
localSimpleTypes.put(name, currentSimpleType);

Map<String, String> attsWithPendingType = pendingSimpleType.get(currentAttributeMap.getType());
if (attsWithPendingType == null) {
Expand All @@ -186,7 +193,14 @@ else if ("simpleType".equals(localName)) {
else {
String name = atts.getValue("name");
currentSimpleType = new SimpleType(name);
simpleTypes.put(name, currentSimpleType);

Map<String, SimpleType> localSimpleTypes = simpleTypes.get("");
if (localSimpleTypes == null)
{
localSimpleTypes = new HashMap<String,SimpleType>();
simpleTypes.put("", localSimpleTypes);
}
localSimpleTypes.put(name, currentSimpleType);
}
}
else if ("restriction".equals(localName)) {
Expand Down Expand Up @@ -278,7 +292,7 @@ private void addAttribute(String name, Attributes atts) {
String type = atts.getValue("type");
if (type == null) //This can happen if the type is defined inline within the attribute
{
pendingAttributeWithInlineType = name;
pendingAttributeWithInlineType = /*"" + currentType + "_" +*/ name;
return;
}
Variable attr = null;
Expand Down Expand Up @@ -345,7 +359,18 @@ private void handlePendingSimpleTypes() {
String simpleTypeName = entry2.getValue();
if (simpleTypeName.contains(":"))
simpleTypeName = simpleTypeName.substring(simpleTypeName.indexOf(":")+1);
SimpleType simpleType = simpleTypes.get(simpleTypeName);

SimpleType simpleType = null;
Map<String, SimpleType> localSimpleTypes = simpleTypes.get(attributeMap.getType());
if (localSimpleTypes != null)
simpleType = localSimpleTypes.get(simpleTypeName);

if (simpleType == null)
{
localSimpleTypes = simpleTypes.get("");
if (localSimpleTypes != null)
simpleType = localSimpleTypes.get(simpleTypeName);
}

if (simpleType != null && attrName != null) {
Variable variable = simpleType.getVariable();
Expand Down

0 comments on commit 5674435

Please sign in to comment.