List of usage examples for org.jdom2 Attribute getNamespaceURI
public String getNamespaceURI()
Attribute
's prefix. From source file:es.upm.dit.xsdinferencer.extraction.extractorImpl.AttributeListInferencerImpl.java
License:Apache License
/** * @see AttributeListInferencer#learnAttributeList(List, int) *///from ww w .j a v a 2s . co m @Override public void learnAttributeList(List<Attribute> attrList, int documentIndex) { checkNotNull(attrList, "'attrList' must not be null"); if (!firstTime) { //First, we mark as optional any known attribute which does not reoccur for (SchemaAttribute schemaAttribute : knownAttributes.keySet()) { boolean found = false; for (Attribute attribute : attrList) { if (attribute.getName().equals(schemaAttribute.getName()) && attribute.getNamespace().getURI().equals(schemaAttribute.getNamespace())) found = true; } if (!found) schemaAttribute.setOptional(true); } } //Now, we learn the information given by this list of atttributes for (Attribute attribute : attrList) { if (attribute.getNamespaceURI().equals(XSI_NAMESPACE_URI)) continue;//Attributes in the XSI namespace are not extracted. SchemaAttribute schemaAttribute = searchSchemaAttribute(attribute.getNamespaceURI(), attribute.getName()); //New attribute if (schemaAttribute == null) { schemaAttribute = new SchemaAttribute(attribute.getName(), attribute.getNamespaceURI(), true, new SimpleType("")); if (firstTime) schemaAttribute.setOptional(false); SimpleTypeInferencer simpleTypeInferencer = InferencersFactory.getInstance() .getSimpleTypeInferencerInstance(schemaAttribute.getNamespace() + config.getTypeNamesAncestorsSeparator() + schemaAttribute.getName(), config); simpleTypeInferencer.learnValue(attribute.getValue(), attribute.getNamespaceURI(), "@" + attribute.getName()); knownAttributes.put(schemaAttribute, simpleTypeInferencer); } //Already known attribute else { knownAttributes.get(schemaAttribute).learnValue(attribute.getValue(), attribute.getNamespaceURI(), "@" + attribute.getName()); } complexTypeStatisticsEntry.registerAttributeOccurrenceInfoCount(schemaAttribute, documentIndex); complexTypeStatisticsEntry.registerValueOfNodeCount(attribute.getValue(), schemaAttribute, documentIndex); String realPathFiltered = TypesExtractorImpl.filterAndJoinRealPath(TypesExtractorImpl .getRealPathOfAttributeUnfiltered(attribute, config, solvedNamespaceToPrefixMapping)); statistics.registerAttributeOccurrenceAtPathCount(realPathFiltered, documentIndex); statistics.registerValueAtPathCount(realPathFiltered, attribute.getValue(), documentIndex); } firstTime = false; }