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); } } } }
if (type.getName() != null) { bindingName = new QName(type.getTargetNamespace(), type.getName()); } else { for (Iterator e = type.getSchema().getElementDeclarations().iterator(); e.hasNext(); ) { XSDElementDeclaration element = (XSDElementDeclaration) e.next(); bindingName = new QName(type.getTargetNamespace(), "_" + element.getName()); if (container.getName() == null) { if (container.getContainer() instanceof XSDElementDeclaration) { XSDElementDeclaration e = (XSDElementDeclaration) container.getContainer(); if (type.getContainer() instanceof XSDElementDeclaration) { XSDElementDeclaration anonymous = (XSDElementDeclaration) type.getContainer(); XSDParticle particle = Schemas.getChildElementParticle( && type.getBaseType() instanceof XSDSimpleTypeDefinition) {
public int length(XSDTypeDefinition definition) { try { XSDSimpleTypeDefinition simple = definition.getSimpleType(); XSDLengthFacet facet = simple.getLengthFacet(); if (facet == null) { return Integer.MAX_VALUE; } return Integer.parseInt(facet.getLexicalValue()); } catch (NumberFormatException ignore) { return Integer.MIN_VALUE; } }
/** * 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; }
if (theBaseTypeDefinition != null && (forceResolve || theBaseTypeDefinition.getContainer() == null)) theBaseTypeDefinition = resolveTypeDefinition(theBaseTypeDefinition.getTargetNamespace(), theBaseTypeDefinition.getName());
XSDTypeDefinition baseType = xsdTypeDefinition.getBaseType(); if (baseType == null || !baseType.hasSameNameAndTargetNamespace(xsdTypeDefinition) || resolveTypeDefinition(xsdTypeDefinition.getName()).getContainer() == null) xsdTypeDefinition.getName());
for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) { XSDTypeDefinition typedef = (XSDTypeDefinition) t.next(); if ((ft.getName() + "_Type").equals(typedef.getName())) { type = typedef; break;
private List types(XSDTypeDefinition base) { List types = (List) cache.get(base); if (types == null) { types = new ArrayList(); XSDTypeDefinition type = base; while (type != null) { types.add(type); // get the next type if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } cache.put(base, types); } return types; }
public IType getSuperType() { XSDTypeDefinition td = getXSDTypeDefinition().getBaseType(); // test to filter out the 'anyType' type ... don't want to see that // if (td != null && !td.getName().equals("anyType")) //$NON-NLS-1$ { return (IType) XSDAdapterFactory.getInstance().adapt(td); } return null; }
public static boolean isPrimitiveType(XSDTypeDefinition type) { if (type instanceof XSDComplexTypeDefinition) return false; XSDTypeDefinition baseType = null; if (type != null) { baseType = type.getBaseType(); XSDTypeDefinition origType = baseType; // KC: although invalid, we need to // prevent cycles and to avoid an // infinite loop while (baseType != null && !XSDConstants.isAnySimpleType(baseType) && !XSDConstants.isAnyType(baseType) && origType != baseType) { type = baseType; baseType = type.getBaseType(); } baseType = type; } else { return false; } return (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(baseType.getTargetNamespace())); }
} else if (parent.getTargetNamespace() != null) { childName = new QName(parent.getTargetNamespace(), child.getName()); } else if (parent.getType().getTargetNamespace() != null) { childName = new QName( parent.getType().getTargetNamespace(), child.getName()); } else { childName = new QName(null, child.getName());
XSDElementDeclaration element = (XSDElementDeclaration ) e.next(); if ( element.getAnonymousTypeDefinition() != null ) { element.getAnonymousTypeDefinition().setName( "_" + element.getName() ); anonymous.add( element.getAnonymousTypeDefinition() ); element.getAnonymousTypeDefinition().setName( type.getName() + "_" + element.getName() ); anonymous.add( element.getAnonymousTypeDefinition() );
theBaseTypeDefinition = handleNewBaseTypeDefinition(complexBaseTypeDefinition.getSimpleType()); if (lowestCommonAncestor instanceof XSDSimpleTypeDefinition && lowestCommonAncestor.getContainer() != null)
protected List<XSDTypeDefinition> getEcoreTypeQNamesAttribute (XSDConcreteComponent xsdConcreteComponent, Element element, String namespace, String attribute) { List<XSDTypeDefinition> result = new ArrayList<XSDTypeDefinition>(); if (element != null && element.hasAttributeNS(namespace, attribute)) { for (StringTokenizer stringTokenizer = new StringTokenizer(element.getAttributeNS(namespace, attribute)); stringTokenizer.hasMoreTokens(); ) { String qName = stringTokenizer.nextToken(); XSDTypeDefinition xsdTypeDefinition = xsdConcreteComponent.resolveTypeDefinitionURI(XSDConstants.lookupQName(element, qName)); if (xsdTypeDefinition.getContainer() != null) { result.add(xsdTypeDefinition); } } } return result; }
/** * Returns whether the type definition has the given namespace and name * or is derived from a type with that namespace and name. * @param xsdTypeDefinition a type definition. * @return whether the type definition has the given namespace and name or is derived from a type with that namespace and name. * @since 2.4 */ public static boolean isOrIsDerivedFrom(XSDTypeDefinition xsdTypeDefinition, String name, String namespace) { Set<XSDTypeDefinition> visited = new HashSet<XSDTypeDefinition>(); while (xsdTypeDefinition != null) { if (xsdTypeDefinition.hasNameAndTargetNamespace(name, namespace)) { return true; } if (!visited.add(xsdTypeDefinition = xsdTypeDefinition.getBaseType())) { return false; } } return false; }
if (theTypeDefinition == null || theTypeDefinition.getContainer() == null) theTypeDefinition == null ? "" : theTypeDefinition.getURI()); theTypeDefinition.getBadTypeDerivation (substitutionGroupAffiliation.getTypeDefinition(), !substitutionGroupExclusions.contains(XSDSubstitutionGroupExclusions.EXTENSION_LITERAL), (XSDDiagnosticSeverity.ERROR_LITERAL, "e-props-correct.3", substitutionGroupAffiliation.getTypeDefinition().getURI()); (XSDDiagnosticSeverity.ERROR_LITERAL, "cos-ct-derived-ok", badTypeDefinition.getURI());
XSDWildcard localWildcard = getAttributeWildcardContent(); XSDWildcard baseWildcard = null; if (theBaseTypeDefinition != null && theBaseTypeDefinition.getContainer() != null) if (!((XSDConcreteComponentImpl)theBaseTypeDefinition).analyze() && !XSDConstants.isURType(theBaseTypeDefinition) && theBaseTypeDefinition.isCircular())
public void run(){ if(fSelectedComponent == null){ return; } if(fSelectedComponent.getSchema() == null){ getSchema().updateElement(true); } DocumentImpl doc = (DocumentImpl) fSelectedComponent.getElement().getOwnerDocument(); doc.getModel().beginRecording( this, RefactoringWizardMessages.MakeAnonymousTypeGlobalAction_text); MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand( fSelectedComponent, getNewDefaultName()); command.run(); doc.getModel().endRecording(this); }
else if (theBaseTypeDefinition.getContainer() == null) createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "_UI_UnresolvedTypeDefinition_message", theBaseTypeDefinition.getURI()); if (getDerivationMethod() == XSDDerivationMethod.RESTRICTION_LITERAL) createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "src-ct.2.2", theBaseTypeDefinition.getURI()); createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "src-ct.1", theBaseTypeDefinition.getURI()); if (xsdComplexTypeDefinition.getFinal().contains(XSDComplexFinal.EXTENSION_LITERAL)) createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "cos-ct-extends.1.1", theBaseTypeDefinition.getURI());
xmls.getTransformer().transform(new DOMSource(xsdType.getElement()), new StreamResult(writer));