attributes.add(use.getAttributeDeclaration()); } else if (content instanceof XSDAttributeGroupDefinition) { attributes.add(use.getAttributeDeclaration());
@Override public boolean isIdentifiable(XSDComplexTypeDefinition typeDefinition) { List attributeUses = typeDefinition.getAttributeUses(); final String idAttName = getId().getLocalPart(); for (Iterator it = attributeUses.iterator(); it.hasNext(); ) { XSDAttributeUse use = (XSDAttributeUse) it.next(); XSDAttributeUseCategory useCategory = use.getUse(); XSDAttributeDeclaration idAtt = use.getAttributeDeclaration(); String targetNamespace = idAtt.getTargetNamespace(); String name = idAtt.getName(); if (getNameSpace().equals(targetNamespace) && idAttName.equals(name)) { if (XSDAttributeUseCategory.REQUIRED_LITERAL.equals(useCategory)) { return true; } } } return false; }
@Override public XSDAttributeDeclaration getDelegate(XSDAttributeUse xsdAttributeUse) { return xsdAttributeUse.getAttributeDeclaration(); } };
protected XSDAttributeDeclaration getXSDAttributeDeclaration() { return getXSDAttributeUse().getAttributeDeclaration(); }
protected void setAttributeType(XSDAttributeUse attributeUse) { setAttributeType(attributeUse.getAttributeDeclaration()); }
/** * This tests whether the combination of given <code>localName</code> and * <code>targetNamespace</code> is shared by an attribute declaration of * an attribute use in the given collection. Returns <code>false</code> * if so, <code>true</code> otherwise. Note that this method is tolerant * of nulls: a result of <code>true</code> is returned if * <code>attributeUse</code> is <code>null</code>, and two null strings * are considered equal. */ protected boolean isUniqueAttributeDeclarationName(String localName, String targetNamespace, Collection<? extends XSDAttributeUse> attributeUses) { if (attributeUses != null) { for (XSDAttributeUse attributeUse : attributeUses) { if (attributeUse.getAttributeDeclaration() != null) { XSDAttributeDeclaration other = attributeUse.getAttributeDeclaration(); if (other.hasNameAndTargetNamespace(localName, targetNamespace)) { return false; } } } } return true; }
public String getTextForAttributeUse(XSDAttributeUse attributeUse, boolean showType) { XSDAttributeDeclaration ad = attributeUse.getAttributeDeclaration(); StringBuffer result = new StringBuffer(); result.append(getTextForAttribute(ad, showType)); /* if (xsdAttributeUse.isSetConstraint()) { if (result.length() != 0) { result.append(" "); } result.append('<'); result.append(xsdAttributeUse.getConstraint()); result.append("=\""); result.append(xsdAttributeUse.getLexicalValue()); result.append("\">"); } */ return result.toString(); }
public boolean visit(XSDTypeDefinition type) { //simple types dont have attributes if (type instanceof XSDSimpleTypeDefinition) { return true; } XSDComplexTypeDefinition cType = (XSDComplexTypeDefinition) type; //get all the attribute content (groups,or uses) and add to q List attContent = cType.getAttributeContents(); for (Iterator itr = attContent.iterator(); itr.hasNext();) { XSDAttributeGroupContent content = (XSDAttributeGroupContent) itr.next(); if (content instanceof XSDAttributeUse) { //an attribute, add it to the list XSDAttributeUse use = (XSDAttributeUse) content; attributes.add(use.getAttributeDeclaration()); } else if (content instanceof XSDAttributeGroupDefinition) { //attribute group, add all atts in group to list XSDAttributeGroupDefinition attGrp = (XSDAttributeGroupDefinition) content; if (attGrp.isAttributeGroupDefinitionReference()) { attGrp = attGrp.getResolvedAttributeGroupDefinition(); } List uses = attGrp.getAttributeUses(); for (Iterator aitr = uses.iterator(); aitr.hasNext();) { XSDAttributeUse use = (XSDAttributeUse) aitr.next(); attributes.add(use.getAttributeDeclaration()); } } } return true; } };
public boolean visit(XSDTypeDefinition type) { //simple types dont have attributes if (type instanceof XSDSimpleTypeDefinition) { return true; } XSDComplexTypeDefinition cType = (XSDComplexTypeDefinition) type; //get all the attribute content (groups,or uses) and add to q List attContent = cType.getAttributeContents(); for (Iterator itr = attContent.iterator(); itr.hasNext();) { XSDAttributeGroupContent content = (XSDAttributeGroupContent) itr.next(); if (content instanceof XSDAttributeUse) { //an attribute, add it to the list XSDAttributeUse use = (XSDAttributeUse) content; attributes.add(use.getAttributeDeclaration()); } else if (content instanceof XSDAttributeGroupDefinition) { //attribute group, add all atts in group to list XSDAttributeGroupDefinition attGrp = (XSDAttributeGroupDefinition) content; if (attGrp.isAttributeGroupDefinitionReference()) { attGrp = attGrp.getResolvedAttributeGroupDefinition(); } List uses = attGrp.getAttributeUses(); for (Iterator aitr = uses.iterator(); aitr.hasNext();) { XSDAttributeUse use = (XSDAttributeUse) aitr.next(); attributes.add(use.getAttributeDeclaration()); } } } return true; } };
private void updateNames(XSDComplexTypeDefinition ct) { Iterator iter = ct.getAttributeContents().iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof XSDAttributeUse) { XSDAttributeUse use = (XSDAttributeUse) obj; XSDAttributeDeclaration attr = use.getAttributeDeclaration(); String attrName = attr.getName(); if (attrName != null) { names.add(attrName); } } } }
public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) { for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) { Object o = it.next(); if (o instanceof XSDAttributeUse) { XSDAttributeUse attributeUse = (XSDAttributeUse)o; concreteComponentList.add(attributeUse.getAttributeDeclaration()); thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration()); } else if (o instanceof XSDAttributeGroupDefinition) { XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition)o; thingsWeNeedToListenTo.add(attrGroup); if (attrGroup.isAttributeGroupDefinitionReference()) { attrGroup = attrGroup.getResolvedAttributeGroupDefinition(); visitAttributeGroupDefinition(attrGroup); } } } }
protected static Map<String, XSDAttributeDeclaration> getProhibitedAttributes(Collection<XSDAttributeGroupContent> xsdAttributeContents) { Map<String, XSDAttributeDeclaration> result = new HashMap<String, XSDAttributeDeclaration>(); for (XSDAttributeGroupContent xsdAttributeGroupContent : xsdAttributeContents) { if (xsdAttributeGroupContent instanceof XSDAttributeGroupDefinition) { XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition)xsdAttributeGroupContent; result.putAll(getProhibitedAttributes(xsdAttributeGroupDefinition.getContents())); } else { XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdAttributeGroupContent; if (xsdAttributeUse.getUse() == XSDAttributeUseCategory.PROHIBITED_LITERAL) { XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); result.put(xsdAttributeDeclaration.getURI(), xsdAttributeDeclaration); } } } return result; }
public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) { for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext();) { Object o = it.next(); if (o instanceof XSDAttributeUse) { XSDAttributeUse attributeUse = (XSDAttributeUse) o; concreteComponentList.add(attributeUse.getAttributeDeclaration()); thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration()); } else if (o instanceof XSDAttributeGroupDefinition) { XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) o; thingsWeNeedToListenTo.add(attrGroup); if (attrGroup.isAttributeGroupDefinitionReference()) { attrGroup = attrGroup.getResolvedAttributeGroupDefinition(); if (attrGroup.getContents().size() == 0) { concreteComponentList.add(new SpaceFiller("attribute")); //$NON-NLS-1$ } visitAttributeGroupDefinition(attrGroup); } } } }
protected static Map<String, XSDAttributeDeclaration> getProhibitedAttributes(Collection<XSDAttributeGroupContent> xsdAttributeContents) { Map<String, XSDAttributeDeclaration> result = new HashMap<String, XSDAttributeDeclaration>(); for (XSDAttributeGroupContent xsdAttributeGroupContent : xsdAttributeContents) { if (xsdAttributeGroupContent instanceof XSDAttributeGroupDefinition) { XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition)xsdAttributeGroupContent; result.putAll(getProhibitedAttributes(xsdAttributeGroupDefinition.getContents())); } else { XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdAttributeGroupContent; if (xsdAttributeUse.getUse() == XSDAttributeUseCategory.PROHIBITED_LITERAL) { XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); result.put(xsdAttributeDeclaration.getURI(), xsdAttributeDeclaration); } } } return result; }
localAttributeUses.add(xsdAttributeUse.getAttributeDeclaration().getURI()); if (!localAttributeUses.contains(xsdAttributeUse.getAttributeDeclaration().getURI()))
/** * Determines if elements of the given complex type definition are required to have an * identifier by looking for a child element of <code>typeDefinition</code> of the form * <code><xs:attribute ref="gml:id" use="required" /></code> * * @param typeDefinition * @return */ private boolean isIdentifiable(XSDComplexTypeDefinition typeDefinition) { List attributeUses = typeDefinition.getAttributeUses(); final String idAttName = GML.getId().getLocalPart(); for (Iterator it = attributeUses.iterator(); it.hasNext();) { XSDAttributeUse use = (XSDAttributeUse) it.next(); XSDAttributeUseCategory useCategory = use.getUse(); XSDAttributeDeclaration idAtt = use.getAttributeDeclaration(); String targetNamespace = idAtt.getTargetNamespace(); String name = idAtt.getName(); if (GML.getNameSpace().equals(targetNamespace) && idAttName.equals(name)) { if (XSDAttributeUseCategory.REQUIRED_LITERAL.equals(useCategory)) { return true; } } } return false; }
@Override protected void validateValue() { XSDSimpleTypeDefinition whiteSpaceEnumeration = ((XSDAttributeUse) ((XSDComplexTypeDefinition) getSimpleTypeDefinition(). getSchema(). getSchemaForSchema(). resolveElementDeclaration("whiteSpace"). getTypeDefinition()). getAttributeContents().get(0)). getAttributeDeclaration().getTypeDefinition(); checkSimpleTypeConstraint (whiteSpaceEnumeration, getLexicalValue(), XSDConstants.PART2, "element-whiteSpace", getElement(), XSDConstants.VALUE_ATTRIBUTE, true); }
@Override protected void validateValue() { XSDSimpleTypeDefinition whiteSpaceEnumeration = ((XSDAttributeUse) ((XSDComplexTypeDefinition) getSimpleTypeDefinition(). getSchema(). getSchemaForSchema(). resolveElementDeclaration("whiteSpace"). getTypeDefinition()). getAttributeContents().get(0)). getAttributeDeclaration().getTypeDefinition(); checkSimpleTypeConstraint (whiteSpaceEnumeration, getLexicalValue(), XSDConstants.PART2, "element-whiteSpace", getElement(), XSDConstants.VALUE_ATTRIBUTE, true); }
public static class FeatureIteratorImpl extends EContentsEList.FeatureIteratorImpl<XSDConcreteComponent> { public FeatureIteratorImpl(EObject eObject) { super(eObject, (EStructuralFeature [])((BasicEList<?>)eObject.eClass().getEAllReferences()).data()); } public FeatureIteratorImpl(EObject eObject, EStructuralFeature [] eStructuralFeatures) { super(eObject, eStructuralFeatures); } @Override protected boolean isIncluded(EStructuralFeature eStructuralFeature) { EReference eReference = (EReference)eStructuralFeature; return !eReference.isTransient(); } } }
public static class FeatureIteratorImpl extends EContentsEList.FeatureIteratorImpl<XSDConcreteComponent> { public FeatureIteratorImpl(EObject eObject) { super(eObject, (EStructuralFeature [])((BasicEList<?>)eObject.eClass().getEAllReferences()).data()); } public FeatureIteratorImpl(EObject eObject, EStructuralFeature [] eStructuralFeatures) { super(eObject, eStructuralFeatures); } @Override protected boolean isIncluded(EStructuralFeature eStructuralFeature) { EReference eReference = (EReference)eStructuralFeature; return !eReference.isTransient(); } } }