boolean sameNameSpace = true;
if (parentElement != null) {
- //QName parentType = parentElement.getType();
String parentNs = elementNsMap.get(parentElement);
sameNameSpace =currentNS.equals(parentNs);
if (!sameNameSpace) {
}
if (schemaElement == null) {
- LocalElement localElement = null;
- //QName type = null;
if (elementStack.isEmpty()) {
schemaElement = new TopLevelElement();
s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
} else {
-
-
-// if (sameNameSpace) {
-// localElement = new LocalElement();
-// schemaElement = localElement;
-// //type = new QName(elementName);
-//
-// } else {
- schemaElement = new TopLevelElement();
- s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
- //type = new QName(SchemaConversionBase.SCHEMA_NS,"element");
- localElement = new LocalElement();
- localElement.setRef(new QName(parseElement.getName().getNamespaceURI(), elementName));
-
-// }
+ schemaElement = new TopLevelElement();
+ s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
}
schemaElement.setName(elementName);
- elementNsMap.put(schemaElement, currentNS);
-// if (sameNameSpace) {
-// schemaElement.setType(new QName(parseElement.getName().getNamespaceURI(),elementName));
-// } else {
-// schemaElement.setType(new QName(parseElement.getName().getNamespaceURI(), elementName));
-// }
- if (!elementStack.isEmpty()) {
- ComplexType complexType = parentElement.getComplexType();
- ExplicitGroup choice = complexType.getChoice();
- if (choice == null) {
- choice = new ExplicitGroup();
- complexType.setChoice(choice);
- choice.setMaxOccurs("unbounded");
- }
- addElement(choice, new QName(SchemaConversionBase.SCHEMA_NS,"element"), localElement);
- }
+ elementNsMap.put(schemaElement, currentNS);
elementMap.get(s).put(elementName, schemaElement);
newElement = true;
}
+ if (parentElement != null) {
+ ComplexType complexType = parentElement.getComplexType();
+ ExplicitGroup choice = complexType.getChoice();
+ if (choice == null) {
+ choice = new ExplicitGroup();
+ complexType.setChoice(choice);
+ choice.setMaxOccurs("unbounded");
+ }
+ LocalElement localElement = new LocalElement();
+ localElement.setRef(new QName(parseElement.getName().getNamespaceURI(), elementName));
+
+ addElement(choice, new QName(SchemaConversionBase.SCHEMA_NS,"element"), localElement);
+ }
+
elementStack.push(schemaElement);
Iterator<Attribute> attributeIterator = parseElement.getAttributes();
Attribute attribute = attributeIterator.next();
if ("http://www.w3.org/XML/1998/namespace".equals(attribute.getName().getNamespaceURI()))
continue;
- addAttribute(attribute, complexType, parseElement.getNamespaceURI(attribute.getName().getPrefix()));
+ addAttribute(attribute, complexType, currentNS);
}
} else {
continue;
org.w3._2001.xmlschema.Attribute schemaAttribute = currentAttributes.get(attribute.getName().getLocalPart());
if (schemaAttribute == null) {
- addAttribute(attribute, complexType, parseElement.getNamespaceURI(attribute.getName().getPrefix()));
+ addAttribute(attribute, complexType, currentNS);
} else {
QName newType = getType(attribute.getValue());
updateAttributeType(schemaAttribute, newType);
// System.out.println("End " + element.getName());
elementStack.pop();
} else if (event.isAttribute()) {
- System.out.println(event);
+
} else if (event.isStartDocument()) {
- System.out.println(event);
+
} else if (event.isEndDocument()) {
} else if (event.isEntityReference()) {
// if (!characters.isWhiteSpace())
// System.out.println(characters.getData());
} else if (event.isNamespace()) {
- System.out.println(event);
+
}
}
}
}
private void addAttribute(Attribute attribute, ComplexType complexType, String currentNS) {
- if (attribute.getName().getLocalPart().equals("Panel.ZIndex"))
- System.out.println();
if (attribute.getName().getNamespaceURI().length() == 0 || attribute.getName().getNamespaceURI().equals(currentNS)) {
org.w3._2001.xmlschema.Attribute schemaAttribute = new org.w3._2001.xmlschema.Attribute();
schemaAttribute.setName(attribute.getName().getLocalPart());
}
}
}
- if ("Panel.ZIndex".equals(schemaAttribute.getName()))
- System.out.println();
complexType.getAttributeOrAttributeGroup().add(schemaAttribute);
}