in src/framework/taespecifierbuilder.cpp [1537:1641]
void XMLParser::buildCapability(AnalysisEngineMetaData & aeMetaData,
DOMElement * descElem) {
assert(EXISTS(descElem));
assert( XMLString::compareString(descElem->getNodeName(), convert(TAG_CAPABILITY)) == 0);
DOMNodeList * children = descElem->getChildNodes();
assert(EXISTS(children));
Capability * capability = new Capability();
size_t i;
for (i=0; i < children->getLength(); i++) {
if ((children->item(i))->getNodeType() != DOMNode::ELEMENT_NODE) {
continue;
}
DOMElement * child = (DOMElement *) children->item(i);
const icu::UnicodeString & childTag = convert(child->getNodeName());
if (childTag.compare(TAG_CAP_LANG_SUPP) == 0) {
DOMNodeList * languages = child->getChildNodes();
size_t j;
for (j=0; j < languages->getLength(); j++) {
if ((languages->item(j))->getNodeType() != DOMNode::ELEMENT_NODE) {
continue;
}
assert(XMLString::compareString((languages->item(j))->getNodeName(), convert(TAG_CAP_LANG)) == 0);
capability->addSupportedLanguage(getSpannedText(languages->item(j)));
}
} else {//it's either input or output capabilities
Capability::EnTypeStyle typeStyle;
if (childTag.compare(TAG_CAP_INPUTS) == 0) {
typeStyle = Capability::INPUT;
} else if (childTag.compare(TAG_CAP_OUTPUTS) == 0) {
typeStyle = Capability::OUTPUT;
}//BSI
else if (childTag.compare(TAG_CAP_INPUT_SOFAS) == 0) {
typeStyle = Capability::INPUTSOFA;
} else if (childTag.compare(TAG_CAP_OUTPUT_SOFAS) == 0) {
typeStyle = Capability::OUTPUTSOFA;
} else {
ErrorMessage errMsg(UIMA_MSG_ID_EXC_UNKNOWN_CONFIG_XML_TAG);
errMsg.addParam(childTag);
errMsg.addParam(ResourceManager::getInstance().getSchemaInfo());
UIMA_EXC_THROW_NEW(InvalidXMLException,
UIMA_ERR_CONFIG_INVALID_XML_TAG,
errMsg,
UIMA_MSG_ID_EXCON_BUILD_TAE_SPEC,
ErrorInfo::unrecoverable);
}
DOMNodeList * types = child->getChildNodes();
size_t j;
for (j=0; j < types->getLength(); j++) {
DOMNode * node = types->item(j);
if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
continue;
}
DOMElement * nodeElem = (DOMElement *) node;
const icu::UnicodeString & nodeTag = convert(nodeElem->getNodeName());
if (nodeTag.compare(TAG_CAP_TYPE) == 0) {
capability->addCapabilityType(getSpannedText(nodeElem), typeStyle);
bool expand = isTrue(convert(nodeElem->getAttribute(convert(ATTR_CAP_FEATURE_ALL))));
if (expand) {
//add all features of this type as well, based on the type information
//in the current specifier
icu::UnicodeString typeName(getSpannedText(nodeElem));
TypeSystemDescription * cpTypeSystemDesc = aeMetaData.getTypeSystemDescription();
if (EXISTS(cpTypeSystemDesc)) { //if there's already a type description in place
const TypeDescription * cpTypeDesc = cpTypeSystemDesc ->getTypeDescriptionConst(typeName);
if (EXISTS(cpTypeDesc)) {
const TypeDescription::TyVecpFeatureDescriptions & featDescs = cpTypeDesc->getFeatureDescriptions();
TypeDescription::TyVecpFeatureDescriptions::const_iterator ite;
for (ite = featDescs.begin(); ite != featDescs.end(); ite++) {
icu::UnicodeString featName(typeName);
featName += UIMA_TYPE_FEATURE_SEPARATOR;
featName += (*ite)->getName();
capability->addCapabilityFeature(featName, typeStyle);
}
}
}
}
} else if (nodeTag.compare(TAG_CAP_FEATURE) == 0) {
capability->addCapabilityFeature(getSpannedText(nodeElem), typeStyle);
}
//BSI
else if (nodeTag.compare(TAG_CAP_SOFA_NAME) == 0) {
capability->addCapabilitySofa(getSpannedText(nodeElem), typeStyle);
} else {
/**
ErrorMessage errMsg(UIMA_MSG_ID_EXC_UNKNOWN_CONFIG_XML_TAG);
errMsg.addParam(nodeTag);
errMsg.addParam(schemaFileName);
UIMA_EXC_THROW_NEW(InvalidXMLException,
UIMA_ERR_CONFIG_INVALID_XML_TAG,
errMsg,
UIMA_MSG_ID_EXCON_BUILD_TAE_SPEC,
ErrorInfo::unrecoverable);
**/
}
}
}
}
aeMetaData.addCapability(capability);
}