System.setProperty(DOMImplementationRegistry.PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMXSImplementationSourceImpl"); DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); com.sun.org.apache.xerces.internal.impl.xs.XSImplementationImpl impl = (XSImplementationImpl) registry.getDOMImplementation("XS-Loader"); XSLoader schemaLoader = impl.createXSLoader(null); XSModel model = schemaLoader.loadURI("src/test/resources/my.xsd");
private static XSFacet getFacet(XSSimpleTypeDefinition simpleType, int kind) { XSObjectList facets = simpleType.getFacets(); for (int i = 0; i < facets.getLength(); i++) { XSFacet facet = (XSFacet) facets.item(i); if (facet.getFacetKind() == kind) { return facet; } } return null; }
public boolean isSimpleValued() { if (this.type.getTypeCategory() == 14) { return true; } if (this.type.getTypeCategory() == 13) { int contentType = ((XSComplexTypeDefinition) this.type) .getContentType(); return contentType == 1; } return false; }
private boolean allowsXLink( XSComplexTypeDefinition typeDef ) { XSObjectList xsObjectList = typeDef.getAttributeUses(); for ( int i = 0; i < xsObjectList.getLength(); i++ ) { XSAttributeDeclaration attr = ( (XSAttributeUse) xsObjectList.item( i ) ).getAttrDeclaration(); if ( "href".equals( attr.getName() ) && XLNNS.equals( attr.getNamespace() ) ) { return true; } } return false; }
public QName getElementType(String namespaceUri, String localName) { XSElementDeclaration element = this.model.getElementDeclaration( localName, namespaceUri); XSTypeDefinition type = element.getTypeDefinition(); String typeNamespaceUri = type.getNamespace(); String typeName = type.getName(); return new QName(typeNamespaceUri, typeName); }
private boolean isGroupTypeWithMultipleOccurs(XSParticle particle) { if (particle == null) return false; XSTerm term = particle.getTerm(); if (term.getType() != XSConstants.MODEL_GROUP) return false; XSModelGroup group = (XSModelGroup) term; final short compositor = group.getCompositor(); switch(compositor) { case XSModelGroup.COMPOSITOR_CHOICE: case XSModelGroup.COMPOSITOR_SEQUENCE: return particle.getMaxOccurs() > 1 || particle.getMaxOccursUnbounded(); default: return false; } }
private static boolean isArrayWrapper(XSTypeDefinition type) { boolean is = false; if(XSTypeDefinition.COMPLEX_TYPE == type.getTypeCategory()) { XSComplexTypeDefinition cType = (XSComplexTypeDefinition)type; XSParticle particle = cType.getParticle(); if(particle != null) { is = particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1; } } return is; }
/** * Optional. Annotation. */ public XSAnnotation getAnnotation() { return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null; }
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); XSImplementation impl = (XSImplementation) registry.getDOMImplementation("XS-Loader"); XSLoader schemaLoader = impl.createXSLoader(null); XSModel xsModel = schemaLoader.loadURI(xsdResource.getURL().getPath()); ((XSComplexTypeDecl) xsModel.getComponents(XSTypeDefinition.COMPLEX_TYPE).itemByName(xsdName, "typeName")).getAttrGrp().getAttributeUses();
public static boolean isComplexTypeDerivedFromSTList(XSComplexTypeDefinition complexTypeDef, short derivationMethod) { XSTypeDefinition baseType = complexTypeDef.getBaseType(); return complexTypeDef.getDerivationMethod() == derivationMethod && baseType instanceof XSSimpleTypeDefinition && ((XSSimpleTypeDefinition)baseType).getVariety() == XSSimpleTypeDefinition.VARIETY_LIST; } // isComplexTypeDerivedFromSTList
/** * @see org.w3c.dom.TypeInfo#getTypeNamespace() */ public String getTypeNamespace() { if (type !=null){ return type.getNamespace(); } return null; }
@Override public String getName() { if (xsSimple == null) return name; return xsSimple.getName(); }
@Override public String getNamespace() { if (xsSimple == null) return namespace; return xsSimple.getNamespace(); } }
/** * [schema default] * * @return The canonical lexical representation of the declaration's {value constraint} value. * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a> */ public String getSchemaDefault() { return fDeclaration == null ? null : fDeclaration.getConstraintValue(); }
/** * [schema default] * * @return The canonical lexical representation of the declaration's {value constraint} value. * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a> */ public String getSchemaDefault() { return fDeclaration == null ? null : fDeclaration.getConstraintValue(); }
/** * Optional. Annotation. */ public XSAnnotation getAnnotation() { return (XSAnnotation) annotations.item(0); }
/** * [schema default] * * @return The canonical lexical representation of the declaration's {value constraint} value. * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a> */ public String getSchemaDefault() { return fDeclaration == null ? null : fDeclaration.getConstraintValue(); }
/** * Optional. Annotation. */ public XSAnnotation getAnnotation() { return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null; }
/** * Optional. Annotation. */ public XSAnnotation getAnnotation() { return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null; }
/** * Optional. Annotation. */ public XSAnnotation getAnnotation() { return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null; }