use of com.sun.xml.xsom.XSSimpleType in project atlasmap by atlasmap.
the class SchemaWriter method restrictionSimpleType.
public void restrictionSimpleType(XSRestrictionSimpleType type) {
if (type.getBaseType() == null) {
// don't print anySimpleType
if (!type.getName().equals("anySimpleType"))
throw new InternalError();
if (!Const.schemaNamespace.equals(type.getTargetNamespace()))
throw new InternalError();
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
println(MessageFormat.format("<restriction{0}>", baseType.isLocal() ? "" : " base=\"{" + baseType.getTargetNamespace() + '}' + baseType.getName() + '\"'));
indent++;
if (baseType.isLocal())
simpleType(baseType);
Iterator itr = type.iterateDeclaredFacets();
while (itr.hasNext()) facet((XSFacet) itr.next());
indent--;
println("</restriction>");
}
use of com.sun.xml.xsom.XSSimpleType in project atlasmap by atlasmap.
the class SchemaInspector method printAttributes.
private void printAttributes(XSComplexType xsComplexType, String rootName, XmlComplexType xmlComplexType) {
Collection<? extends XSAttributeUse> c = xsComplexType.getDeclaredAttributeUses();
for (XSAttributeUse aC : c) {
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
XSAttributeDecl attributeDecl = aC.getDecl();
xmlField.setName(getNameNS(attributeDecl));
if (attributeDecl.getDefaultValue() != null) {
xmlField.setValue(attributeDecl.getDefaultValue().value);
} else if (attributeDecl.getFixedValue() != null) {
xmlField.setValue(attributeDecl.getFixedValue().value);
}
xmlField.setPath(rootName + "/" + "@" + getNameNS(attributeDecl));
FieldType attrType = getFieldType(attributeDecl.getType().getName());
xmlField.setFieldType(attrType);
if (xmlField.getFieldType() == null) {
// check the simple types in the schema....
XSSimpleType simpleType = xsComplexType.getRoot().getSimpleType(xsComplexType.getTargetNamespace(), attributeDecl.getType().getName());
if (simpleType != null) {
FieldType fieldType = getFieldType(simpleType.getBaseType().getName());
xmlField.setFieldType(fieldType);
xmlField.setTypeName(attributeDecl.getType().getName());
if (simpleType.asRestriction() != null) {
mapRestrictions(xmlField, simpleType.asRestriction());
}
} else {
// cannot figure it out....
xmlField.setFieldType(FieldType.UNSUPPORTED);
}
}
xmlComplexType.getXmlFields().getXmlField().add(xmlField);
}
}
use of com.sun.xml.xsom.XSSimpleType in project atlasmap by atlasmap.
the class SchemaWriter method schema.
public void schema(XSSchema s) {
// QUICK HACK: don't print the built-in components
if (s.getTargetNamespace().equals(Const.schemaNamespace))
return;
println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
indent++;
Iterator itr;
itr = s.iterateAttGroupDecls();
while (itr.hasNext()) attGroupDecl((XSAttGroupDecl) itr.next());
itr = s.iterateAttributeDecls();
while (itr.hasNext()) attributeDecl((XSAttributeDecl) itr.next());
itr = s.iterateComplexTypes();
while (itr.hasNext()) complexType((XSComplexType) itr.next());
itr = s.iterateElementDecls();
while (itr.hasNext()) elementDecl((XSElementDecl) itr.next());
itr = s.iterateModelGroupDecls();
while (itr.hasNext()) modelGroupDecl((XSModelGroupDecl) itr.next());
itr = s.iterateSimpleTypes();
while (itr.hasNext()) simpleType((XSSimpleType) itr.next());
indent--;
println("</schema>");
}
use of com.sun.xml.xsom.XSSimpleType in project atlasmap by atlasmap.
the class SchemaWriter method dump.
private void dump(XSAttributeDecl decl, String additionalAtts) {
XSSimpleType type = decl.getType();
println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>", decl.getName(), additionalAtts, type.isLocal() ? "" : MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()), decl.getFixedValue() == null ? "" : " fixed=\"" + decl.getFixedValue() + '\"', decl.getDefaultValue() == null ? "" : " default=\"" + decl.getDefaultValue() + '\"', type.isLocal() ? "" : " /"));
if (type.isLocal()) {
indent++;
simpleType(type);
indent--;
println("</attribute>");
}
}
use of com.sun.xml.xsom.XSSimpleType in project atlasmap by atlasmap.
the class SchemaWriter method unionSimpleType.
public void unionSimpleType(XSUnionSimpleType type) {
final int len = type.getMemberSize();
StringBuffer ref = new StringBuffer();
for (int i = 0; i < len; i++) {
XSSimpleType member = type.getMember(i);
if (member.isGlobal())
ref.append(MessageFormat.format(" '{'{0}'}'{1}", member.getTargetNamespace(), member.getName()));
}
if (ref.length() == 0)
println("<union>");
else
println("<union memberTypes=\"" + ref + "\">");
indent++;
for (int i = 0; i < len; i++) {
XSSimpleType member = type.getMember(i);
if (member.isLocal())
simpleType(member);
}
indent--;
println("</union>");
}
Aggregations