Search in sources :

Example 11 with XSSimpleType

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

the class SchemaWriter method listSimpleType.

public void listSimpleType(XSListSimpleType type) {
    XSSimpleType itemType = type.getItemType();
    if (itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />", itemType.getTargetNamespace(), itemType.getName()));
    }
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType)

Example 12 with XSSimpleType

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

the class redefine method action3.

private void action3() throws SAXException {
    XSSimpleType oldSt = $runtime.currentSchema.getSimpleType(newSt.getName());
    if (oldSt == null) {
        $runtime.reportError(Messages.format(Messages.ERR_UNDEFINED_SIMPLETYPE, newSt.getName()));
    } else {
        newSt.redefine((SimpleTypeImpl) oldSt);
        $runtime.currentSchema.addSimpleType(newSt, true);
    }
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType)

Example 13 with XSSimpleType

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

the class SchemaTreeTraverser method unionSimpleType.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSSimpleTypeVisitor#unionSimpleType(com.sun.xml.xsom.XSUnionSimpleType)
     */
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}", new Object[] { member.getTargetNamespace(), member.getName() }));
        }
    }
    String name = (ref.length() == 0) ? "Union" : ("Union memberTypes=\"" + ref + "\"");
    SchemaTreeNode newNode = new SchemaTreeNode(name, type.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;
    for (int i = 0; i < len; i++) {
        XSSimpleType member = type.getMember(i);
        if (member.isLocal()) {
            simpleType(member);
        }
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSIdentityConstraint(com.sun.xml.xsom.XSIdentityConstraint)

Example 14 with XSSimpleType

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

the class XmlSchemaInspector method printAttributes.

private void printAttributes(XSComplexType xsComplexType, XmlComplexType parentXmlComplexType) {
    Collection<? extends XSAttributeUse> c = xsComplexType.getDeclaredAttributeUses();
    for (XSAttributeUse aC : c) {
        XmlField xmlField = AtlasXmlModelFactory.createXmlField();
        XSAttributeDecl attributeDecl = aC.getDecl();
        xmlField.setName(getNameNS(attributeDecl));
        xmlField.setAttribute(true);
        if (attributeDecl.getDefaultValue() != null) {
            xmlField.setValue(attributeDecl.getDefaultValue().value);
        } else if (attributeDecl.getFixedValue() != null) {
            xmlField.setValue(attributeDecl.getFixedValue().value);
        }
        xmlField.setPath(parentXmlComplexType.getPath() + "/" + "@" + 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);
            }
        }
        parentXmlComplexType.getXmlFields().getXmlField().add(xmlField);
    }
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType) XmlField(io.atlasmap.xml.v2.XmlField) XSAttributeDecl(com.sun.xml.xsom.XSAttributeDecl) XSAttributeUse(com.sun.xml.xsom.XSAttributeUse) FieldType(io.atlasmap.v2.FieldType)

Aggregations

XSSimpleType (com.sun.xml.xsom.XSSimpleType)14 XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)4 XSComplexType (com.sun.xml.xsom.XSComplexType)3 XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)3 Iterator (java.util.Iterator)3 XSAttGroupDecl (com.sun.xml.xsom.XSAttGroupDecl)2 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)2 XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSIdentityConstraint (com.sun.xml.xsom.XSIdentityConstraint)2 FieldType (io.atlasmap.v2.FieldType)2 XmlField (io.atlasmap.xml.v2.XmlField)2 XSFacet (com.sun.xml.xsom.XSFacet)1 XSSchema (com.sun.xml.xsom.XSSchema)1 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)1 XSOMParser (com.sun.xml.xsom.parser.XSOMParser)1 SAXException (org.xml.sax.SAXException)1