use of com.sun.xml.xsom.XSElementDecl 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.XSElementDecl in project atlasmap by atlasmap.
the class SchemaTreeTraverser method particle.
/* (non-Javadoc)
* @see com.sun.xml.xsom.visitor.XSContentTypeVisitor#particle(com.sun.xml.xsom.XSParticle)
*/
public void particle(XSParticle part) {
BigInteger i;
StringBuffer buf = new StringBuffer();
i = part.getMaxOccurs();
if (i.equals(BigInteger.valueOf(XSParticle.UNBOUNDED))) {
buf.append(" maxOccurs=\"unbounded\"");
} else {
if (!i.equals(BigInteger.ONE)) {
buf.append(" maxOccurs=\"" + i + "\"");
}
}
i = part.getMinOccurs();
if (!i.equals(BigInteger.ONE)) {
buf.append(" minOccurs=\"" + i + "\"");
}
final String extraAtts = buf.toString();
part.getTerm().visit(new XSTermVisitor() {
public void elementDecl(XSElementDecl decl) {
if (decl.isLocal()) {
SchemaTreeTraverser.this.elementDecl(decl, extraAtts);
} else {
// reference
SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format("Element ref=\"'{'{0}'}'{1}\"{2}", new Object[] { decl.getTargetNamespace(), decl.getName(), extraAtts }), decl.getLocator());
currNode.add(newNode);
}
}
public void modelGroupDecl(XSModelGroupDecl decl) {
// reference
SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format("Group ref=\"'{'{0}'}'{1}\"{2}", new Object[] { decl.getTargetNamespace(), decl.getName(), extraAtts }), decl.getLocator());
currNode.add(newNode);
}
public void modelGroup(XSModelGroup group) {
SchemaTreeTraverser.this.modelGroup(group, extraAtts);
}
public void wildcard(XSWildcard wc) {
SchemaTreeTraverser.this.wildcard(wc, extraAtts);
}
});
}
use of com.sun.xml.xsom.XSElementDecl in project narayana by jbosstm.
the class NBFSchemaParser method findElementType.
private void findElementType(XSComplexType xtype) {
XSContentType xsContentType = xtype.getContentType();
XSParticle particle = xsContentType.asParticle();
if (particle != null) {
XSTerm term = particle.getTerm();
if (term.isModelGroup()) {
XSModelGroup xsModelGroup = term.asModelGroup();
XSParticle[] particles = xsModelGroup.getChildren();
for (XSParticle p : particles) {
XSTerm pterm = p.getTerm();
if (pterm.isElementDecl()) {
XSElementDecl element = pterm.asElementDecl();
String name = element.getName();
log.debug(name);
XSType type = element.getType();
while (type != null) {
String typeName = type.getName();
if (typeName != null && (typeName.equals("long") || typeName.equals("string") || typeName.equals("integer") || typeName.equals("float") || typeName.endsWith("_type"))) {
log.debug(typeName);
flds.put(name, typeName);
break;
}
type = type.getBaseType();
}
}
}
}
}
}
use of com.sun.xml.xsom.XSElementDecl in project citygml4j by citygml4j.
the class SchemaWriter method particle.
public void particle(XSParticle part) {
int i;
StringBuffer buf = new StringBuffer();
i = part.getMaxOccurs().intValue();
if (i == XSParticle.UNBOUNDED)
buf.append(" maxOccurs=\"unbounded\"");
else if (i != 1)
buf.append(" maxOccurs=\"").append(i).append('\"');
i = part.getMinOccurs().intValue();
if (i != 1)
buf.append(" minOccurs=\"").append(i).append('\"');
final String extraAtts = buf.toString();
part.getTerm().visit(new XSTermVisitor() {
public void elementDecl(XSElementDecl decl) {
if (decl.isLocal())
SchemaWriter.this.elementDecl(decl, extraAtts);
else {
// reference
println(MessageFormat.format("<element ref=\"'{'{0}'}'{1}\"{2}/>", decl.getTargetNamespace(), decl.getName(), extraAtts));
}
}
public void modelGroupDecl(XSModelGroupDecl decl) {
// reference
println(MessageFormat.format("<group ref=\"'{'{0}'}'{1}\"{2}/>", decl.getTargetNamespace(), decl.getName(), extraAtts));
}
public void modelGroup(XSModelGroup group) {
SchemaWriter.this.modelGroup(group, extraAtts);
}
public void wildcard(XSWildcard wc) {
SchemaWriter.this.wildcard("any", wc, extraAtts);
}
});
}
use of com.sun.xml.xsom.XSElementDecl in project citygml4j by citygml4j.
the class ElementDecl method isGeometryProperty.
public boolean isGeometryProperty() {
if (typeFlag.contains(TypeFlag.GEOMETRY_PROPERTY))
return true;
else if (typeFlag.contains(TypeFlag.NO_GEOMETRY_PROPERTY))
return false;
boolean isGeometryProperty = false;
for (XSElementDecl child : getChildElements()) {
Schema childSchema = schema.handler.getSchema(child.getTargetNamespace());
List<ElementDecl> childElementDecls = childSchema.getElementDecls(child.getName());
if (childElementDecls.size() == 1) {
if (childElementDecls.get(0).isGeometry())
isGeometryProperty = true;
} else {
for (GMLCoreModule module : GMLCoreModule.getInstances()) {
XSSchema gml = schema.schemaSet.getSchema(module.getNamespaceURI());
if (gml == null)
continue;
switch(module.getVersion()) {
case v3_1_1:
isGeometryProperty = child.getType().isDerivedFrom(gml.getType("AbstractGeometryType"));
break;
}
if (isGeometryProperty)
break;
}
}
if (isGeometryProperty)
break;
}
if (isGeometryProperty) {
typeFlag.add(TypeFlag.GEOMETRY_PROPERTY);
typeFlag.add(TypeFlag.NO_FEATURE_PROPERTY);
} else
typeFlag.add(TypeFlag.NO_GEOMETRY_PROPERTY);
return isGeometryProperty;
}
Aggregations