You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2007/05/17 00:09:50 UTC

svn commit: r538759 - in /incubator/uima/uimacpp/trunk/src/cas: uima/xmlwriter.hpp xmiwriter.cpp xmlwriter.cpp

Author: eae
Date: Wed May 16 15:09:49 2007
New Revision: 538759

URL: http://svn.apache.org/viewvc?view=rev&rev=538759
Log:
UIMA-403 Bhavani's patch

Modified:
    incubator/uima/uimacpp/trunk/src/cas/uima/xmlwriter.hpp
    incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
    incubator/uima/uimacpp/trunk/src/cas/xmlwriter.cpp

Modified: incubator/uima/uimacpp/trunk/src/cas/uima/xmlwriter.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmlwriter.hpp?view=diff&rev=538759&r1=538758&r2=538759
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmlwriter.hpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmlwriter.hpp Wed May 16 15:09:49 2007
@@ -154,6 +154,7 @@
     bool isReferenceType(Type const & t) const;
     bool enqueueIndexed(FeatureStructure const &fs, int sofa);
     bool enqueueUnindexed(FeatureStructure const &fs);
+		void writeStringArray(ostream & os, StringArrayFS const & array, char const * tag);
   public:
     XCASWriter(CAS const & crCAS, bool bAddDocBuffer);
     ~XCASWriter();

Modified: incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp?view=diff&rev=538759&r1=538758&r2=538759
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp Wed May 16 15:09:49 2007
@@ -195,7 +195,7 @@
      Type type = allTypes.at(i);
      lowlevel::TyFSType typecode = uima::internal::FSPromoter::demoteType(type);
      //cout << "Mapping " << type.getName() << endl;
-		 UnicodeStringRef name = type.getName();
+     UnicodeStringRef name = type.getName();
      xmiTypeNames[typecode] = uimaTypeName2XmiElementName(name);
      // this also populats the nsUriToPrefix map
    }
@@ -299,8 +299,8 @@
 
  void XmiWriter::writeView(ostream & os,int sofaXmiId, vector<lowlevel::TyFS>& members) {
    UnicodeString viewType(UnicodeString("uima.cas.View"));
-	 UnicodeStringRef uref(viewType.getBuffer(), viewType.length());
-	 XmlElementName * elemName = uimaTypeName2XmiElementName(uref);
+   UnicodeStringRef uref(viewType.getBuffer(), viewType.length());
+   XmlElementName * elemName = uimaTypeName2XmiElementName(uref);
 
    stringstream membersString;
    for (size_t i = 0; i < members.size(); i++) {
@@ -318,13 +318,13 @@
      }
    }
 
-	 //remove leading and trailing blanks
-	 string outstr = membersString.str();
-	 size_t startpos = outstr.find_first_not_of(" ");
-	 size_t endpos = outstr.find_last_not_of(" ");
-	 if (string::npos != startpos && string::npos != endpos) {
-		 outstr = outstr.substr(startpos, endpos-startpos+1);
-	 } 
+   //remove leading and trailing blanks
+   string outstr = membersString.str();
+   size_t startpos = outstr.find_first_not_of(" ");
+   size_t endpos = outstr.find_last_not_of(" ");
+   if (string::npos != startpos && string::npos != endpos) {
+	 outstr = outstr.substr(startpos, endpos-startpos+1);
+   } 
 
    if (sofaXmiId !=0 || outstr.size() > 0) {
      os << "<" << elemName->qualifiedName;
@@ -546,8 +546,10 @@
       case internal::gs_tyStringArrayType: {
         StringArrayFS arrayfs(fs);
         size_t n = arrayfs.size();
+				UnicodeString ustr;
         for (size_t i=0; i < n;i++) {
-          str << "<" << tag << ">" << arrayfs.get(i) << "</" << tag << ">";
+          normalize( arrayfs.get(i), ustr );
+          str << "<" << tag << ">" << ustr << "</" << tag << ">";
         }		  
         break;
                                            }
@@ -1142,9 +1144,11 @@
                                     }
     case internal::gs_tyNEStringListType:  {
       StringListFS curNode(fs);
+      UnicodeString ustr;
       while (!curNode.isEmpty()) { 
-        string head = curNode.getHead().asUTF8();
-        str << "<" << tag << ">" << head << "</" << tag << ">";
+        ///string head = curNode.getHead().asUTF8();
+        normalize(curNode.getHead(), ustr);
+        str << "<" << tag << ">" << ustr << "</" << tag << ">";
         curNode = curNode.getTail();
         int addr = internal::FSPromoter::demoteFS(curNode);
         if (visited[addr] == addr) {

Modified: incubator/uima/uimacpp/trunk/src/cas/xmlwriter.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmlwriter.cpp?view=diff&rev=538759&r1=538758&r2=538759
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmlwriter.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmlwriter.cpp Wed May 16 15:09:49 2007
@@ -463,6 +463,23 @@
     }
   }
 
+	void XCASWriter::writeStringArray(ostream & os, StringArrayFS const & array, char const * tag) {
+    size_t i;
+		UnicodeString ustr;
+    if (array.size() > 0) {
+      os << " size=\"" << array.size() << "\">" << endl;
+      for (i=0; i<array.size(); ++i) {
+        os << "  <" << tag << ">";
+				normalize(array.get(i),ustr);
+        os << ustr;
+        os << "</" << tag << ">" << endl;
+      }
+      os << " </" << array.getType().getName() << ">" << endl;
+    } else {
+      os << " size=\"0\"/>" << endl;
+    }
+  }
+
   void XCASWriter::writeFSFlat(ostream & os,
                                FeatureStructure const & fs,
                                vector<int>* indexInfo) {
@@ -493,7 +510,7 @@
       } else if ( t == iv_floatArrayType ) {
         writeArray( os, FloatArrayFS(fs), "i");
       } else if ( t == iv_stringArrayType ) {
-        writeArray( os, StringArrayFS(fs), "i");
+        writeStringArray( os, StringArrayFS(fs), "i");
       } else if ( t == iv_byteArrayType ) {
         ByteArrayFS array(fs);
         if (array.size() > 0) {
@@ -700,6 +717,7 @@
 
 
 /* ----------------------------------------------------------------------- */
+