Search in sources :

Example 1 with XSWildcard

use of com.sun.xml.xsom.XSWildcard 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 XSWildcard

use of com.sun.xml.xsom.XSWildcard in project atlasmap by atlasmap.

the class SchemaWriter method dumpComplexTypeAttribute.

private void dumpComplexTypeAttribute(XSComplexType type) {
    Iterator itr;
    itr = type.iterateAttGroups();
    while (itr.hasNext()) dumpRef((XSAttGroupDecl) itr.next());
    itr = type.iterateDeclaredAttributeUses();
    while (itr.hasNext()) attributeUse((XSAttributeUse) itr.next());
    XSWildcard awc = type.getAttributeWildcard();
    if (awc != null)
        wildcard("anyAttribute", awc, "");
}
Also used : XSAttGroupDecl(com.sun.xml.xsom.XSAttGroupDecl) Iterator(java.util.Iterator) XSAttributeUse(com.sun.xml.xsom.XSAttributeUse) XSWildcard(com.sun.xml.xsom.XSWildcard)

Example 3 with XSWildcard

use of com.sun.xml.xsom.XSWildcard 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

XSWildcard (com.sun.xml.xsom.XSWildcard)3 XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSModelGroup (com.sun.xml.xsom.XSModelGroup)2 XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)2 XSTermVisitor (com.sun.xml.xsom.visitor.XSTermVisitor)2 BigInteger (java.math.BigInteger)2 XSAttGroupDecl (com.sun.xml.xsom.XSAttGroupDecl)1 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)1 Iterator (java.util.Iterator)1