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=6621cc716f17853f3549644bf2f6b42cf8cc6d44;hb=HEAD;hp=049b08775cb915dfd28628851f28b38634966c11;hpb=fc60d91049c46ee5b6107da4d4c54eada4a9f21c;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 049b087..6621cc7 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 @@ -28,6 +28,7 @@ import org.w3._2001.xmlschema.Any; import org.w3._2001.xmlschema.Attribute; import org.w3._2001.xmlschema.AttributeGroup; import org.w3._2001.xmlschema.ComplexContent; +import org.w3._2001.xmlschema.ComplexRestrictionType; import org.w3._2001.xmlschema.ComplexType; import org.w3._2001.xmlschema.Element; import org.w3._2001.xmlschema.ExplicitGroup; @@ -204,10 +205,12 @@ public final class SchemaConversionBase { private Map complexTypeName = new HashMap<>(); private Map simpleTypeName = new HashMap<>(); private Map modelGroupName = new HashMap<>(); + private Map attrName = new HashMap<>(); private Map elements = new HashMap<>(); private Map complexTypes = new HashMap<>(); private Map simpleTypes = new HashMap<>(); private Map modelGroups = new HashMap<>(); + private Map attributes = new HashMap<>(); private SchemaObject _getWithName(QName name) { SchemaObject obj = elementName.get(name.getLocalPart()); @@ -215,6 +218,8 @@ public final class SchemaConversionBase { obj = complexTypeName.get(name.getLocalPart()); if (obj == null) obj = simpleTypeName.get(name.getLocalPart()); + if (obj == null) + obj = attrName.get(name.getLocalPart()); return obj; } @@ -373,7 +378,9 @@ public final class SchemaConversionBase { SchemaObject obj = new SchemaObject(this,simpleType); stack.push(obj); } else if (attrs instanceof Attribute) { - // Attributes are not cached + Attribute attribute = (Attribute)attrs; + SchemaObject obj = new SchemaObject(this, attribute); + stack.push(obj); } else if (attrs instanceof AttributeGroup) { // Attribute groups are not cached } else if (attrs instanceof NamedGroup) { @@ -466,6 +473,12 @@ public final class SchemaConversionBase { modelGroups.put(e, object); break; } + case ATTRIBUTE: { + Attribute e = object.getAttribute(); + attrName.put(e.getName(), object); + attributes.put(e, object); + break; + } } } // while } @@ -529,6 +542,13 @@ public final class SchemaConversionBase { QName type = extensionType.getBase(); return type; } + ComplexRestrictionType restriction = complexContent.getRestriction(); + if (restriction != null) + return restriction.getBase(); + } + if (complexType.isMixed()) { + // Handle characters data of mixed ComplexType as String. + return new QName(SCHEMA_NS, "string"); } return null; } @@ -730,13 +750,30 @@ public final class SchemaConversionBase { return type; } + private SchemaObject _getAttribute(QName name) { + return attrName.get(name.getLocalPart()); + } + protected Attribute getRefAttribute(QName ref) { - for (OpenAttrs attrs : schema.getSimpleTypeOrComplexTypeOrGroup()) { - if (attrs instanceof TopLevelAttribute) { - TopLevelAttribute attribute = (TopLevelAttribute)attrs; - if (attribute.getName().equals(ref.getLocalPart())) - return attribute; - } +// for (OpenAttrs attrs : schema.getSimpleTypeOrComplexTypeOrGroup()) { +// if (attrs instanceof TopLevelAttribute) { +// TopLevelAttribute attribute = (TopLevelAttribute)attrs; +// if (attribute.getName().equals(ref.getLocalPart())) +// return attribute; +// } +// } + SchemaObject obj = _getAttribute(ref); + if (obj != null) + return obj.getAttribute(); + if (ref.getNamespaceURI() != null) { + for (SchemaConverter sc : converter.getConverter(ref.getNamespaceURI())) { + if (sc.base != null) { + obj = sc.base._getAttribute(ref); + if (obj != null) { + return obj.getAttribute(); + } + } + } } return null; }