@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; }
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; }
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; }
/** * 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; }
if (xsdAttributeUse.getUse() != XSDAttributeUseCategory.PROHIBITED_LITERAL)
if (xsdAttributeUse.getUse() != XSDAttributeUseCategory.PROHIBITED_LITERAL)
public void execute() { Element element = component.getElement(); try { beginRecording(element); String currentMin = element.getAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); removeMinOccursAttribute = (currentMin == null) ? true : false; if (component instanceof XSDParticle) { oldMinOccurs = ((XSDParticle) component).getMinOccurs(); ((XSDParticle) component).setMinOccurs(newMinOccurs); } else if (component instanceof XSDAttributeUse) { oldMinOccurs = (((XSDAttributeUse) component).getUse() == XSDAttributeUseCategory.REQUIRED_LITERAL ? 1 : 0); if (newMinOccurs == 1) ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.REQUIRED_LITERAL); else ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.OPTIONAL_LITERAL); } } finally { endRecording(); } }