for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) { XSDTypeDefinition typedef = (XSDTypeDefinition) t.next(); if ((ft.getName() + "_Type").equals(typedef.getName())) { type = typedef; break;
/** * Returns all the types defined in <param>schema</param> whose names are * included in the specified set of names. * <p> * If <tt>names</tt> is null or empty all types are returned. * </p> * @param schema the schema. * @param names the names of types to include. * * @return A list of types, including anonymous complex types. */ public static List types( XSDSchema schema, Set names ) { List allTypes = allTypes( schema ); if ( names != null && !names.isEmpty() ) { for (Iterator t = allTypes.iterator(); t.hasNext(); ) { XSDTypeDefinition type = (XSDTypeDefinition) t.next(); if ( type.getName() != null && names.contains(type.getName())) { continue; } t.remove(); } } return allTypes; } }
protected void buildComplexTypeIndex() { complexTypeIndex = new HashMap(); for (int i = 0; i < schemas.length; i++) { XSDSchema schema = schemas[i]; for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) { XSDTypeDefinition type = (XSDTypeDefinition) t.next(); if (type instanceof XSDComplexTypeDefinition) { QName qName = new QName(type.getTargetNamespace(), type.getName()); complexTypeIndex.put(qName, type); } } } }
@Override public AttributeType buildSuper() { XSDTypeDefinition baseType = xsdType.getBaseType(); if (baseType != null && baseType.getName() != null && !baseType.equals(xsdType)) { return createType(baseType, DUMMY_DEPTH); } else { return null; } }
@Override public AttributeType buildSuper() { XSDTypeDefinition baseType = xsdType.getBaseType(); if (baseType != null && baseType.getName() != null && !baseType.equals(xsdType)) { return createType(baseType, Integer.MAX_VALUE); } else { return null; } } };
protected void buildSimpleTypeIndex() { simpleTypeIndex = new HashMap(); for (int i = 0; i < schemas.length; i++) { XSDSchema schema = schemas[i]; for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) { XSDTypeDefinition type = (XSDTypeDefinition) t.next(); if (type instanceof XSDSimpleTypeDefinition) { QName qName = new QName(type.getTargetNamespace(), type.getName()); simpleTypeIndex.put(qName, type); } } } }
protected final AttributeType xsAnyType() { XSDSchema schema = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); for ( Iterator i = schema.getTypeDefinitions().iterator(); i.hasNext(); ) { XSDTypeDefinition t = (XSDTypeDefinition) i.next(); if ( XS.ANYTYPE.getLocalPart().equals( t.getName() ) ) { return findType(t); } } throw new IllegalStateException("XS schema not present"); }
/** * Returns true if the <code>typeDefinition</code> is based on provided <code>superNS</code>. * * @param typeDefinition * @param superNS * @return */ private static boolean isBasedOn(XSDTypeDefinition typeDefinition, final String superNS) { XSDTypeDefinition baseType; String targetNamespace; String name; while ((baseType = typeDefinition.getBaseType()) != null) { targetNamespace = baseType.getTargetNamespace(); name = baseType.getName(); if (XS.NAMESPACE.equals(targetNamespace) && XS.ANYTYPE.getLocalPart().equals(name)) { // break the loop or this goes forever return false; } if (superNS.equals(targetNamespace)) { return true; } typeDefinition = baseType; } return false; }
/** * Provide an explicit mapping from an XSD type * @param namespace * @param name */ public void addTypeMapping(String namespace, String name, AttributeType gtType) { if (namespace == null) { namespace = schema.getTargetNamespace(); } assert name != null; //find the type in the xsd schema List typeDefs = schema.getTypeDefinitions(); for (Iterator itr = typeDefs.iterator(); itr.hasNext();) { XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next(); String tns = xsdType.getTargetNamespace(); String tn = xsdType.getName(); if (namespace.equals(tns) && name.equals(tn)) { types.put(xsdType, gtType); return; } } throw new IllegalArgumentException("Type: [" + namespace + "," + name + "] not found"); }
/** * Returns <code>true</code> if <code>typeDefinition</code> is derived from a type named <code> * superTypeName</code> * * @param typeDefinition * @param superTypeName * @return */ private static boolean isDerivedFrom( XSDTypeDefinition typeDefinition, final Name superTypeName) { XSDTypeDefinition baseType; final String superNS = superTypeName.getNamespaceURI(); final String superName = superTypeName.getLocalPart(); String targetNamespace; String name; while ((baseType = typeDefinition.getBaseType()) != null) { targetNamespace = baseType.getTargetNamespace(); name = baseType.getName(); if (XS.NAMESPACE.equals(targetNamespace) && XS.ANYTYPE.getLocalPart().equals(name)) { return false; } if (superNS.equals(targetNamespace) && superName.equals(name)) { return true; } typeDefinition = baseType; } return false; }
for (Iterator itr = types.iterator(); itr.hasNext();) { XSDTypeDefinition type = (XSDTypeDefinition)itr.next(); if (type.getName() == null) continue; if (!ns.equals(type.getTargetNamespace())) continue; stringBuffer.append(type.getName()); stringBuffer.append(TEXT_13); stringBuffer.append(ns); stringBuffer.append(TEXT_14); stringBuffer.append(type.getName()); stringBuffer.append(TEXT_15);
XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next(); if (xsdType.getName() == null) { continue; logger.fine(xsdType.getName()); createType((XSDSimpleTypeDefinition) xsdType, 0); XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next(); if (xsdType.getName() == null) { continue; logger.fine(xsdType.getName()); try { createType((XSDComplexTypeDefinition) xsdType, 0);
protected AttributeType createType( XSDSimpleTypeDefinition xsdType, int depth ) { if (types.containsKey(xsdType)) { return (AttributeType) types.get(xsdType); } //import? if (!xsdType.getTargetNamespace().equals(schema.getTargetNamespace())) { return (AttributeType) findType(xsdType); } //first build super type AttributeType superType = null; XSDTypeDefinition baseType = xsdType.getBaseType(); if ((baseType != null) && !baseType.equals(xsdType)) { if (baseType.getName() != null) { //ignore unamed types //superType = createType((XSDSimpleTypeDefinition)baseType); superType = createType(baseType, depth+1); assert superType != null; } } //TODO: actually derive valus from type AttributeType gtType = factory.createAttributeType( name(xsdType), Object.class, false, false, Collections.EMPTY_LIST, superType, null ); types.put(xsdType, gtType); return gtType; }
element.getAnonymousTypeDefinition().setName( type.getName() + "_" + element.getName() ); anonymous.add( element.getAnonymousTypeDefinition() );
} else if (!boundedBy.equals(contentName)) { XSDTypeDefinition contentType = content.getTypeDefinition(); if (contentType.getName() == null) { while (contentType != null && contentType.getName() == null) { XSDTypeDefinition baseType = contentType.getBaseType(); if (contentType.equals(baseType)) { new QName(contentType.getTargetNamespace(), contentType.getName());
if (childElement .getType() .getName() .equals(complex.getType().getName().getLocalPart())) {
Name typeName = Types.typeName(typeDef.getTargetNamespace(), typeDef.getName()); AttributeType attType = typeRegistry.get(typeName);
if (hasToBeRegistered) { String targetNamespace = typeDefinition.getTargetNamespace(); String name = typeDefinition.getName(); Name typeName = Types.typeName(targetNamespace, name); type = getAttributeType(typeName, typeDefinition, crs);