Search in sources :

Example 1 with XSTermVisitor

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);
        }
    });
}
Also used : XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) BigInteger(java.math.BigInteger) XSElementDecl(com.sun.xml.xsom.XSElementDecl) XSWildcard(com.sun.xml.xsom.XSWildcard) XSTermVisitor(com.sun.xml.xsom.visitor.XSTermVisitor) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Example 2 with XSTermVisitor

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);
        }
    });
}
Also used : XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) BigInteger(java.math.BigInteger) XSElementDecl(com.sun.xml.xsom.XSElementDecl) XSWildcard(com.sun.xml.xsom.XSWildcard) XSTermVisitor(com.sun.xml.xsom.visitor.XSTermVisitor) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Aggregations

XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSModelGroup (com.sun.xml.xsom.XSModelGroup)2 XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)2 XSWildcard (com.sun.xml.xsom.XSWildcard)2 XSTermVisitor (com.sun.xml.xsom.visitor.XSTermVisitor)2 BigInteger (java.math.BigInteger)2