X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.xml.sax%2Fsrc%2Forg%2Fsimantics%2Fxml%2Fsax%2FSchemaConversionBase.java;h=cb0f7629f2ca38f28f16a7d9cc11313f6dc6444c;hb=ab4fc05981803ce2c430f93f34b8b6a8f85a53ce;hp=f349cde8960667c3ac33004c6fd1c5d62c538c5f;hpb=04f3fb6796cd6225be090e1e1feb866ae0d03173;p=simantics%2Finterop.git diff --git a/org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java b/org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java index f349cde..cb0f762 100644 --- a/org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java +++ b/org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java @@ -111,7 +111,7 @@ public final class SchemaConversionBase { schemaTypes.put("unsignedByte", new TypeEntry("L0.Byte", "Bindings.BYTE", "byte", "0","java.lang.Byte.parseByte(",")","java.lang.Byte.toString(",")")); schemaTypes.put("long", new TypeEntry("L0.Long", "Bindings.LONG", "long", "0","java.lang.Long.parseLong(",")","java.lang.Long.toString(",")")); schemaTypes.put("unsignedLong", new TypeEntry("L0.Long", "Bindings.LONG", "long", "0","java.lang.Long.parseLong(",")","java.lang.Long.toString(",")")); - schemaTypes.put("base64Binary", new TypeEntry("L0.ByteArray", "Bindings.BYTE_ARRAY", "byte[]", "new byte[0]","java.util.Base64.getDecoder().decode(",")","java.util.Base64.getEncoder().encodeToString(",")")); + schemaTypes.put("base64Binary", new TypeEntry("L0.ByteArray", "Bindings.BYTE_ARRAY", "byte[]", "new byte[0]","java.util.Base64.getDecoder().decode(",".replaceAll(\"\\n\", \"\").getBytes(java.nio.charset.StandardCharsets.UTF_8))","java.util.Base64.getEncoder().encodeToString(",")")); l0Types.put("doubleArray", new TypeEntry("L0.DoubleArray", "Bindings.DOUBLE_ARRAY", "double[]", null,null,null,"java.lang.Double.toString(",")")); l0Types.put("stringArray", new TypeEntry("L0.StringArray", "Bindings.STRING_ARRAY", "string[]", null,null,null,"","")); @@ -1359,6 +1359,7 @@ public final class SchemaConversionBase { public static class Inheritance { public String baseClass; + public String additionalClass; public InheritanceType type; public TypeEntry atomicType; @@ -1392,12 +1393,15 @@ public final class SchemaConversionBase { QName type = topLevelElement.getType(); if (!type.getNamespaceURI().equals(SCHEMA_NS)) { SchemaObject obj = complexTypeName.get(type.getLocalPart()); - // if (obj == null) - // obj = simpleTypeName.get(type.getLocalPart()); if (obj != null) { inheritance.baseClass = getName(obj); inheritance.type = InheritanceType.ComplexType; } + else { + obj = simpleTypeName.get(type.getLocalPart()); + if (obj != null) + getAtomicTypeInheritance(type, inheritance); + } } else { TypeEntry entry = getTypeEntry(type); if (entry != null) { @@ -1454,6 +1458,9 @@ public final class SchemaConversionBase { ExtensionType extensionType = simpleContent.getExtension(); if (extensionType != null) { type = extensionType.getBase(); + SchemaObject simpleType = getSimpleType(type); + if (simpleType != null) + inheritance.additionalClass = getName(simpleType); getAtomicTypeInheritance(type, inheritance); } } @@ -1469,9 +1476,9 @@ public final class SchemaConversionBase { */ public void getAtomicTypeInheritance(QName type, Inheritance inheritance) { if (!type.getNamespaceURI().equals(SCHEMA_NS)) { - SchemaObject obj = getWithName(type); - if (obj.getType() != ObjectType.SIMPLE_TYPE) - throw new RuntimeException("SimpleContent does not use SimpleType definition"); + SchemaObject obj = getSimpleType(type); + if (obj == null) + throw new RuntimeException("Cannot locate SimpleType " + type.getLocalPart()); SimpleType simpleType = obj.getSimpleType(); type = getSimpleTypeBase(simpleType); getAtomicTypeInheritance(type, inheritance);