import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
String pluginName;
- private boolean useElementNSforAttributes = true; // If true, attributes with undefined namespace are written to the same name space as teh element. If false. the attributes are written to the root namespace.
- private boolean ignoreAttributeNS = true; // Completely ignore attribute namespaces. When true, all attributes are written to the elements.
+ private boolean useElementNSforAttributes = true; // If true, attributes with undefined namespace are written to the same name space as the element. If false. the attributes are written to the root namespace.
+ private boolean ignoreAttributeNS = false; // Completely ignore attribute namespaces. When true, all attributes are written to the elements.
+ private String ignorePattern = "(\\w)*"; // Ignore attribute namespaces. When pattern exists, and local name of a attribute matches the regexp, the interpreted namespace is ignored.
+ private boolean nonStandardBooleans = false; // Accept non standard boolean values (True, False).
private String[] header;
org.w3._2001.xmlschema.Attribute schemaAttribute = updateAttributeType(localAttribute, newType);
String attrNs = getNS(attribute, currentNS);
- if (!ignoreAttributeNS && attribute.getName().getNamespaceURI().length() > 0) {
+ if (!ignoreAttributeNs(attribute) && attribute.getName().getNamespaceURI().length() > 0) {
// Attribute has explicit ns definition.
if (localAttribute.getRef() != null) {
// current local attribute is reference, check that the namespaces match
}
private String getNS(Attribute attribute, String currentNS) {
- if (ignoreAttributeNS)
+ if (ignoreAttributeNs(attribute))
return currentNS;
String attrNs = attribute.getName().getNamespaceURI();
if (attrNs.length() == 0) {
}
+
+ private boolean ignoreAttributeNs(Attribute attribute) {
+ if (ignoreAttributeNS)
+ return true;
+
+
+ if (ignorePattern != null) {
+ return attribute.getName().getLocalPart().matches(ignorePattern);
+ }
+ return false;
+ }
+
+
private org.w3._2001.xmlschema.Attribute addAttribute(Attribute attribute, ComplexType complexType, String currentNS) {
String attrNs = getNS(attribute, currentNS);
String attrName = attribute.getName().getLocalPart();
private QName getType(String value) {
- if ("true".equals(value) || "false".equals(value)) // || "1".equals(value) || "0".equals(value))
- return new QName(SchemaConversionBase.SCHEMA_NS, "boolean");
+ if (!nonStandardBooleans) {
+ if ("true".equals(value) || "false".equals(value)) // || "1".equals(value) || "0".equals(value))
+ return new QName(SchemaConversionBase.SCHEMA_NS, "boolean");
+ } else {
+ if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {
+ return new QName(SchemaConversionBase.SCHEMA_NS, "boolean");
+ }
+ }
try {
Integer.parseInt(value);
return new QName(SchemaConversionBase.SCHEMA_NS, "integer");
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;
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;
}