in src/cas/xmlwriter.cpp [162:239]
void XMLDumpWriter::writeFS(int iTab, ostream& os, lowlevel::TyFS tyFS, bool bWriteShortStyle=false) const {
icu::UnicodeString usTab = getTab(iTab);
lowlevel::TyFSType tyFSType = iv_rFSHeap.getType(tyFS);
os << usTab << "<" << gs_cpszFSTagName << " type=\"" << iv_rTypeSystem.getTypeName(tyFSType) << "\"";
os << " id=\"id" << (long)iv_rFSHeap.getUniqueID(tyFS) << "\"";
uima::lowlevel::IndexRepository const & crIxRep = iv_crCAS.getIndexRepository();
//if a feature value-FS is not in any index, e.g. a List FS,
//it will be dumped in its expanded
//form (i.e. with all features)
if (bWriteShortStyle && crIxRep.contains(tyFS)) {
os << "/>" << endl;
return;
}
os << ">" << endl;
if ( iv_addDocument && iv_rTypeSystem.subsumes( iv_tyAnnotationType, tyFSType ) ) {
AnnotationFS fs(internal::FSPromoter::promoteFS(tyFS, iv_crCAS ));
UnicodeStringRef ulsSpan = fs.getCoveredText();
icu::UnicodeString usNormalizedSpan;
normalize(ulsSpan, usNormalizedSpan);
os << "<annotation_span>" << usNormalizedSpan << "</annotation_span>" << endl;
}
/* TBD: when can this happen ? */
if (tyFSType == iv_tyStringType) {
UnicodeStringRef ulsString = iv_rFSHeap.getFSAsString(tyFS);
icu::UnicodeString usNormalizedString;
normalize(ulsString, usNormalizedString);
os << "<string_value>" << usNormalizedString << "</string_value>" << endl;
os << "</" << gs_cpszFSTagName << ">" << endl;
return;
}
vector<lowlevel::TyFSFeature> vecFeatures;
iv_rTypeSystem.getAppropriateFeatures( tyFSType, vecFeatures );
size_t i;
for (i=0; i<vecFeatures.size(); ++i) {
lowlevel::TyFSFeature tyFeat = vecFeatures[i];
lowlevel::TyFeatureOffset tyOffset = iv_rTypeSystem.getFeatureOffset( tyFeat );
lowlevel::TyFSType tyRange = iv_rTypeSystem.getRangeType( tyFeat );
lowlevel::TyFS tyValue = iv_rFSHeap.getFeatureWithOffset( tyFS, tyOffset );
icu::UnicodeString newTab = getTab(iTab + TAB_INCREMENT);
if (tyRange == iv_tyIntegerType) {
os << newTab << "<" << gs_cpszFeatTagName << " name=\"" << iv_rTypeSystem.getFeatureName( tyFeat ) << "\"";
os << " value=\"" << lowlevel::FSHeap::getFSAsInt(tyValue) << "\" />" << endl;
} else if (tyRange == iv_tyFloatType) {
os << newTab << "<" << gs_cpszFeatTagName << " name=\"" << iv_rTypeSystem.getFeatureName( tyFeat ) << "\"";
os << " value=\"" << lowlevel::FSHeap::getFSAsFloat(tyValue) << "\" />" << endl;
} else if (tyRange == iv_tyStringType) {
if (tyValue != 0) {
UnicodeStringRef ulsString = iv_rFSHeap.getFSAsString(tyValue);
icu::UnicodeString usNormalized;
normalize(ulsString, usNormalized);
os << newTab << "<" << gs_cpszFeatTagName <<" name=\"" << iv_rTypeSystem.getFeatureName( tyFeat ) << "\"";
os << " value=\"" << usNormalized << "\" />" << endl;
}
} else if (iv_rTypeSystem.subsumes(iv_tyArrayType, tyRange)) {
writeArray(iTab, os, tyFeat, tyValue, tyRange, newTab);
} else {
// "normal" FS
if (tyValue != 0) {
os << newTab << "<" << gs_cpszFeatTagName << " name=\"" << iv_rTypeSystem.getFeatureName( tyFeat ) << "\"";
os << ">" << endl;
writeFS(iTab + (2*TAB_INCREMENT), os, tyValue, true);
os << newTab << "</"<< gs_cpszFeatTagName << ">" << endl;
}
}
}
os << usTab << "</"<< gs_cpszFSTagName << ">" << endl;
}