use of com.sun.xml.xsom.visitor.XSTermVisitor in project atlasmap by atlasmap.
the class SchemaWriter method particle.
public void particle(XSParticle part) {
BigInteger i;
StringBuilder buf = new StringBuilder();
i = part.getMaxOccurs();
if (i.equals(BigInteger.valueOf(XSParticle.UNBOUNDED)))
buf.append(" maxOccurs=\"unbounded\"");
else if (!i.equals(BigInteger.ONE))
buf.append(" maxOccurs=\"").append(i).append('\"');
i = part.getMinOccurs();
if (!i.equals(BigInteger.ONE))
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.visitor.XSTermVisitor 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);
}
});
}
Aggregations