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/04/13 20:16:41 UTC

svn commit: r528573 [1/4] - in /incubator/uima/uimacpp/trunk/src: cas/ cas/uima/ test/data/ExampleCas/ test/src/

Author: eae
Date: Fri Apr 13 11:16:39 2007
New Revision: 528573

URL: http://svn.apache.org/viewvc?view=rev&rev=528573
Log:
UIMA-371 Bhavani's port of XMI serialization (new files)

Added:
    incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp   (with props)
    incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp   (with props)
    incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp   (with props)
    incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp   (with props)
    incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/cas/xmideserializer_handler.cpp
    incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/newprimitives.xcas
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/newprimitivesPartialTypeSystem.xml
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/newprimitivesTypeSystem.xml
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/partialTestTypeSystem.xml
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/testIndexes.xml
    incubator/uima/uimacpp/trunk/src/test/data/ExampleCas/testTypeSystem_withMultiRefs.xml
    incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.cpp
    incubator/uima/uimacpp/trunk/src/test/src/test_xmideserialization.vcproj   (with props)

Added: incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp?view=auto&rev=528573
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp Fri Apr 13 11:16:39 2007
@@ -0,0 +1,140 @@
+#ifndef UIMA_XMIDESERIALIZER_HPP
+#define UIMA_XMIDESERIALIZER_HPP
+/** \file xmideserializer.hpp .
+-----------------------------------------------------------------------------
+
+
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description:
+
+-----------------------------------------------------------------------------
+
+    \brief Deserializes cas data from XMI format into a CAS
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp"
+
+#include <iostream>
+#include <vector>
+#include <set>
+
+#include "xercesc/framework/LocalFileInputSource.hpp"
+#include "xercesc/framework/MemBufInputSource.hpp"
+
+#include "uima/featurestructure.hpp"
+#include "uima/lowlevel_typedefs.hpp"
+#include "uima/typesystem.hpp"
+#include "uima/xmishareddata.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+  namespace lowlevel {
+    class IndexABase;
+    class FSHeap;
+    class TypeSystem;
+  }
+}
+
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+
+/**
+ * The XmiDeserializer deserializes cas data in XMI format into a CAS.
+ * Only FeatureStructures with types that are represented in the input CAS
+ * TypeSystem will be deserialized into the CAS.
+ */
+namespace uima {
+
+  /**
+   * The XmiDeserializer class provides static methods to deserializes cas data  
+   * in XMI format into a CAS.
+   */
+
+  class UIMA_LINK_IMPORTSPEC XmiDeserializer {
+  private:
+
+
+  public:
+    /** Constructor **/
+    XmiDeserializer();
+    /** Destructor **/
+    ~XmiDeserializer();
+
+    /**
+     * Deserialize given an XMI filename and input CAS 
+     */
+    static void deserialize(char const * xmifilename, CAS &);
+
+    /**
+     * Deserialize given an XMI filename UnicodeString and input CAS 
+     */
+    static void deserialize(UnicodeString & xmifilename, CAS &);
+
+    /**
+     * Deserialize given an XMI InputSource and input CAS 
+     */
+    static void deserialize(InputSource const & crInputSource, CAS &);
+  
+    /**
+     * Deserialize given an XMI InputSource and input CAS and XmiSerializationSharedData 
+     */
+    static void deserialize(InputSource const & crInputSource, CAS &, XmiSerializationSharedData & sharedData);
+  
+	/**
+     * Deserialize given an XMI filename and input CAS , and
+		 * XmiSerializationData.
+     */
+    static void deserialize(char const * xmifilename, CAS &, XmiSerializationSharedData & sharedData);
+
+    /**
+     * Deserialize given an XMI filename UnicodeString, input CAS, and
+		 * XmiSerializationData.
+     */
+    static void deserialize(UnicodeString & xmifilename, CAS &, XmiSerializationSharedData & sharedData);
+
+  };
+
+}
+
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif

Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp?view=auto&rev=528573
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp Fri Apr 13 11:16:39 2007
@@ -0,0 +1,239 @@
+/** \file xmideserializer_handler.hpp .
+
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+
+    \brief  SAX2 handler for reading XMI into a CAS.
+
+-------------------------------------------------------------------------- */
+#ifndef __UIMA_XMIDESER_HANDLER_HPP
+#define __UIMA_XMIDESER_HANDLER_HPP
+
+
+// ---------------------------------------------------------------------------
+//  Includes
+// ---------------------------------------------------------------------------
+
+#include "uima/pragmas.hpp" //must be first to surpress warnings
+#include <map>
+#include <stack>
+#include <utility>
+#include "xercesc/sax2/DefaultHandler.hpp"
+#include "uima/internal_casimpl.hpp"
+#include "xmishareddata.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+  class FeatureStructure;
+  class FSIndexRepository;
+  class SofaFS;
+  class CAS;
+  class AnnotationFS;
+  class AnnotatorContext;
+  namespace lowlevel {
+    class IndexRepository;
+    class FSHeap;
+    class TypeSystem;
+  }
+  namespace internal {
+    class CASImpl;
+  }
+}
+
+XERCES_CPP_NAMESPACE_USE
+
+
+namespace uima {
+
+  /**
+     The class <TT>XmiDeserializerHandler</TT> implements a SAX2 handler for XMI format
+  */
+
+#define DOC_STATE                       0
+#define FS_STATE                        1
+#define FEAT_STATE                      2
+#define FEAT_CONTENT_STATE              3
+#define IGNORING_XMI_ELEMENTS_STATE     4
+           
+  class  XmiDeserializerHandler : public DefaultHandler {
+  public:
+    // -----------------------------------------------------------------------
+    //  Constructors and Destructor
+    // -----------------------------------------------------------------------  
+    XmiDeserializerHandler(CAS & cas, XmiSerializationSharedData * xmiSharedData);   
+		~XmiDeserializerHandler();
+
+    void startDocument();
+    void startElement(const   XMLCh* const    uri,
+                      const   XMLCh* const    localname,
+                      const   XMLCh* const    qname,
+                      const Attributes& attrs);
+    void characters(const XMLCh* const chars,
+                    const unsigned int length);
+    void endDocument();
+    void endElement(const XMLCh* const uri,
+                    const XMLCh* const localname,
+                    const XMLCh* const qname
+                   );
+    void ignorableWhitespace(const XMLCh* const chars,
+                             const unsigned int length);
+    void setDocumentLocator(const Locator* const locator);
+
+
+    void warning(const SAXParseException& exception);
+    void error(const SAXParseException& exception);
+    void fatalError(const SAXParseException& exception);
+
+
+  private:
+  
+    //void readFS(UnicodeString & qualifiedName, const Attributes & attrs);
+    void readFS(UnicodeString & nsUri,
+		        UnicodeString & localName,
+				    UnicodeString & qualifiedName, 
+				    const Attributes & attrs);
+    void readFS(lowlevel::TyFS addr, const Attributes  & attrs, bool toIndex);
+    void handleFeature(lowlevel::TyFS addr, 
+		         UnicodeString & featName, 
+					   UnicodeString & featVal, 
+					   bool lenient);
+	  void handleFeature(Type & type, lowlevel::TyFS addr, 
+					   lowlevel::TyFSFeature featCode, 
+					   UnicodeString & featVal,
+             bool lenient);
+
+    void finalizeFS(int addr);
+    void finalizeArray(Type & type, lowlevel::TyFS addr); 
+  
+    const Locator *  iv_locator;
+    CAS * iv_cas;
+    internal::CASImpl & iv_casimpl;
+    const lowlevel::TypeSystem * iv_typesystem;
+    int iv_state;
+    UnicodeString buffer;
+
+    // The address of the most recently created FS.  Needed for array elements
+    // and embedded feature values.
+    lowlevel::TyFS currentAddr;
+
+    // The name of the content feature, if we've seen one.
+    UnicodeString currentContentFeat;
+
+    // The current position when parsing array elements.
+    size_t arrayPos;
+
+    // The type of the array we're currently reading.  Needed for proper
+    // treatment of array element values.
+    lowlevel::TyFS arrayType;
+
+    // SofaFS type
+    int sofaTypeCode;
+
+    // Store IndexRepositories in a vector;
+    vector<uima::lowlevel::IndexRepository *> indexRepositories;
+
+    // Store CAS Views in a vector
+    vector<CAS*> tcasInstances;
+
+    int nextIndex;
+
+		UnicodeString xmiElementName2uimaTypeName(UnicodeString& nameSpaceURI, UnicodeString& localName);
+		int createByteArray(UnicodeString& currentArrayElements, int currentArrayId);
+		void remapFSListHeads(int addr);
+
+		void tokenize(UnicodeString&, vector<string>&);
+		int createIntList(  vector<string>& featVal);
+		int createFloatList(  vector<string>& featVal);
+		int createStringList(  vector<string>& featVal);
+		int createFSList(  vector<string>& featVal);
+
+		void addArrayElement(lowlevel::TyFS addr,lowlevel::TyFSType arrayType, 
+											int arrayPos, string & buffer);
+
+		void handleFeature(lowlevel::TyFS addr, UnicodeString & featName,
+												vector<string> & featVal);
+
+		void handleFeature(lowlevel::TyFS addr, lowlevel::TyFSFeature featCode,
+								lowlevel::TyFSType rangeTypeCode,vector<string> & featVal);
+
+		int createArray(  lowlevel::TyFSType typeCode,
+								vector<string>& featVal, int xmiID);
+
+		void processView(int sofaXmiId, UnicodeString & membersString) ;
+		int getFsAddrForXmiId(int xmiId);
+		void addToOutOfTypeSystemData(XmlElementName * xmlElementName, const Attributes & attrs);
+		void addOutOfTypeSystemFeature(OotsElementData * ootsElem, 
+					UnicodeString & featName, vector<UnicodeString> & featVals);
+
+		// container for data shared between the XmiCasSerialier and
+		// XmiDeserializer, to support things such as consistency of IDs across
+		// multiple serializations.  This is also where the map from xmi:id to
+		// FS address is stored.
+		XmiSerializationSharedData * sharedData;  
+		bool ownsSharedData;
+
+		//Current out-of-typesystem element, if any
+		OotsElementData * outOfTypeSystemElement;
+
+		// Store address of every FS we've deserialized, since we need to back
+		// and apply fix-ups afterwards.
+		vector<int> deserializedFsAddrs;
+
+		// map from namespace prefixes to URIs.
+		map<UnicodeString, UnicodeString> nsPrefixToUriMap;
+		// map from xmi namespace  to uima namespace 
+		map<UnicodeString, UnicodeString> xmiNamespaceToUimaNamespaceMap;
+
+		//typename - values
+		map<UnicodeString, vector<UnicodeString>* > multiValuedFeatures; 
+		int ignoreDepth;
+
+		// The type of the most recently created FS. Needed for arrays, also
+		// useful for embedded feature values.
+		Type currentType;
+
+		// the ID and values of arrays are stored on startElement, then used on
+		// endElement to actually create the array. This is because in the case of
+		// String arrays serialized with the values as child elements, we can't create
+		// the array until we've seen all of the child elements.
+		int currentArrayId;
+		UnicodeString currentArrayElements;
+
+		int nextSofaNum; //number of sofas found so far
+
+		// Store a separate vector of FSList nodes that were deserialized 
+		// from multivalued properties.
+		// These are special because their "head" feature needs remapping but their "tail" feature
+		// doesn't.
+		vector<int> fsListNodesFromMultivaluedProperties;
+		bool lenient;
+
+		static char const  * XMI_ID_ATTR_NAME;
+		static char const  * TRUE_VALUE;
+		static char const  * DEFAULT_CONTENT_FEATURE;
+		static char const  * DEFAULT_NAMESPACE_URI;
+
+  };
+
+} // namespace uima
+
+#endif //__UIMA_XMIDESER_HANDLER_HPP
+

Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/xmideserializer_handler.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp?view=auto&rev=528573
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp Fri Apr 13 11:16:39 2007
@@ -0,0 +1,502 @@
+#ifndef UIMA_XMISHAREDDATA_HPP
+#define UIMA_XMISHAREDDATA_HPP
+/** \file xmlwriter.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description:
+
+-----------------------------------------------------------------------------
+
+   \brief Used to output the CAS in XCAS format
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp"
+
+#include <iostream>
+#include <vector>
+#include <set>
+#include <sstream>
+#include <map>
+
+#include "uima/msg.h"
+#include "uima/exceptions.hpp"
+using namespace std;
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+namespace uima {
+
+class XmlElementName {
+  public:
+	  string nsUri;
+	  string shortName;
+	  string qualifiedName;
+	  XmlElementName(string ns, string sname, string qname) :
+		nsUri(ns), shortName(sname), qualifiedName(qname) {}
+  };
+
+/**
+ * Data structure representing an XML attribute.
+ */
+class XmlAttribute {
+public:
+  string name;
+  string value;
+  
+  XmlAttribute(UnicodeString name, UnicodeString value) {
+    this->name = ((UnicodeStringRef)name).asUTF8();
+    this->value = ((UnicodeStringRef)value).asUTF8();
+  }
+  XmlAttribute(string name, string value) {
+    this->name = name;
+    this->value = value;
+  }
+};
+
+ /**
+   * Data structure holding all information about an XMI element
+   * containing an out-of-typesystem FS.
+   */
+  class OotsElementData {
+  public:
+    /**
+     * xmi:id of the element
+     */
+    int xmiId;
+
+    /**
+     * Name of the element, including XML namespace.
+     */
+    XmlElementName * elementName;
+
+    /**
+     * List of XmlAttribute objects each holding name and value of an attribute.
+     */
+    vector<XmlAttribute*>  attributes;
+    
+    /**
+     * Map qualified name of an attribute to a list of strings that contain
+	 * the values of the element. Use to store the
+     * child elements representing features of this out-of-typesystem element.
+     */
+    map<string, vector<string>* > childElements;
+
+	OotsElementData() : elementName(0) {}
+
+	~OotsElementData() {
+	  if (elementName != NULL) {
+	    delete elementName;
+		elementName=0;
+	  }
+	  for (size_t i=0; i < attributes.size();i++) {
+		if (attributes.at(i) != NULL) {
+	      delete attributes.at(i);
+		}
+	  }
+	  map<string, vector<string>* >::iterator ite;
+	  for (ite=childElements.begin(); ite != childElements.end();ite++) {
+	    if (ite->second != NULL) {
+		  delete ite->second;
+		}
+	  }
+    }
+  };
+  
+  /** 
+   * Data structure holding the index and the xmi:id of an array or list element that
+   * is a reference to an out-of-typesystem FS.
+   */
+  class XmiArrayElement {
+  public:
+    int index;
+    int xmiId;
+
+    XmiArrayElement(int index, int xmiId) {
+      this->index = index;
+      this->xmiId = xmiId;
+    }
+  };
+/**
+ * Holds information that is shared between the XmiCasSerializer and the XmiCasDeserializer. This
+ * allows consistency of XMI IDs across serializations, and also provides the ability to filter out
+ * some FSs during serialization (e.g. to send to a service) and then reintegrate those FSs during
+ * the next deserialization.
+ * 
+ */
+class UIMA_LINK_IMPORTSPEC XmiSerializationSharedData {
+  private:
+  /**
+   * A map from FeatureStructure address to XMI ID. This is built during deserialization, then used
+   * by the next serialization to ensure consistent IDs.
+   */
+    map<int, int> fsAddrToXmiIdMap;
+   /** 
+   * A map from xmi:id to FeatureStructure address.  This is populated whenever
+   * an XMI element is serialized or deserialized.  It is used by the
+   * getFsAddrForXmiId() method, necessary to support merging multiple XMI
+   * CASes into the same CAS object.
+   **/
+   map<int,int> xmiIdToFsAddrMap;
+  
+  /**
+   * List of OotsElementData objects, each of which captures information about
+   * incoming XMI elements that did not correspond to any type in the type system.
+   */
+  vector<OotsElementData*> ootsFs;
+  
+  /**
+   * Map that from the xmi:id  Sofa to a List of xmi:id's  for
+   * the out-of-typesystem FSs that are members of that Sofa's view.
+   */
+  map<int,vector<int>*> ootsViewMembers;
+
+  /** Map from Feature Structure address (Integer) to OotsElementData object, capturing information 
+   * about out-of-typesystem features that were part of an in-typesystem FS.  These include both
+   * features not defined in the typesystem and features that are references to out-of-typesystem
+   * elements.  This information needs to be included when the FS is subsequently serialized.
+   */
+  map<int, OotsElementData*> ootsFeatures;
+  
+  /** Map from Feature Structure address (Integer) of an FSArray to a list of 
+   * {@link XmiArrayElement} objects, each of which holds an index and an xmi:id
+   * for an out-of-typesystem array element.
+   */
+  map<int,vector<XmiArrayElement*>*> ootsArrayElements;
+  
+
+  /**
+   * The maximum XMI ID used in the serialization. Used to generate unique IDs if needed.
+   */
+    int maxXmiId;
+
+public:
+  XmiSerializationSharedData() : maxXmiId(0) {
+  }
+  ~XmiSerializationSharedData() {
+    for (size_t i=0; i < ootsFs.size(); i++) {
+      if (ootsFs.at(i) != NULL) {
+        delete ootsFs.at(i);
+      }
+    }
+
+    map<int,vector<XmiArrayElement*>*>::iterator ite;
+    for (ite = ootsArrayElements.begin(); ite != ootsArrayElements.end();ite++) {
+      if (ite->second != NULL) {
+        vector<XmiArrayElement*>* vec =  ite->second;
+        for (size_t i=0; i < vec->size(); i++) {
+          if (vec->at(i) != NULL) {
+            delete vec->at(i);
+          }
+        }
+      }
+    }
+  }
+
+  void addIdMapping(int fsAddr, int xmiId) { 
+    fsAddrToXmiIdMap[fsAddr] = xmiId;
+    xmiIdToFsAddrMap[xmiId] = fsAddr;
+    if (xmiId > maxXmiId)
+      maxXmiId = xmiId;
+  }
+
+  int getXmiId(int fsAddr) {
+    // see if we already have a mapping
+    map<int,int>::iterator ite = fsAddrToXmiIdMap.find(fsAddr);
+    if (ite != fsAddrToXmiIdMap.end()) {
+      return ite->second;
+    } else { // no mapping for this FS. Generate a unique ID
+      // to be sure we get a unique Id, increment maxXmiId and use that
+      fsAddrToXmiIdMap[fsAddr] = ++maxXmiId;
+      xmiIdToFsAddrMap[maxXmiId] = fsAddr;
+      return maxXmiId;
+    }
+  }
+   /**
+   * Gets the FS address that corresponds to the given xmi:id, in the most
+   * recent serialization or deserialization.
+   *   
+   * @param xmiId an xmi:id from the most recent XMI CAS that was serialized
+   *   or deserialized.
+   * @return the FS address of the FeatureStructure corresponding to that
+   *   xmi:id, -1 if none.
+   */
+  int getFsAddrForXmiId(int xmiId) {
+	  map<int,int>::iterator ite =  xmiIdToFsAddrMap.find(xmiId);
+	  if (ite != xmiIdToFsAddrMap.end() ) 
+		  return ite->second;
+	  else  {
+		  //cout << __FILE__ << __LINE__ << " getFsAddrForXmiId() could not find xmiid " << xmiId << endl; 
+      return -1;	   
+			/**ErrorInfo errInfo;
+		  errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+		  ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+		  msg.addParam("getFSAddrForXmiId Unknown xmiId");
+		  msg.addParam(xmiId);
+		  errInfo.setMessage(msg);
+		  errInfo.setSeverity(ErrorInfo::unrecoverable);
+		  ExcIllFormedInputError exc(errInfo);
+		  throw exc;**/ 
+	  }
+  }
+  
+ 
+
+  /**
+   * Records information about an XMI element that was not an instance of any type in the type system.
+   * @param elemData information about the out-of-typesystem XMI element
+   */
+  void addOutOfTypeSystemElement(OotsElementData * elemData) {
+    this->ootsFs.push_back(elemData);
+    //check if we need to update max ID
+    int xmiId = elemData->xmiId;
+    if (elemData->xmiId > maxXmiId)
+      maxXmiId = elemData->xmiId;
+  }
+
+  /**
+   * Gets a List of {@link OotsElementData} objects, each of which describes an
+   * incoming XMI element that did not correspond to a Type in the TypeSystem.
+   * @return List of {@link OotsElementData} objects
+   */
+  vector<OotsElementData *> & getOutOfTypeSystemElements() {
+    return this->ootsFs;
+  }
+  
+  /**
+   * Records that an out-of-typesystem XMI element should be a member of the
+   * specified view.
+   * @param sofaXmiId xmi:id of a Sofa
+   * @param memberXmiId xmi:id of an out-of-typesystem element that should be
+   *   a member of the view for the given Sofa
+   */
+  void addOutOfTypeSystemViewMember(int sofaXmiId, int memberXmiId) {
+    vector<int> * memberList = 0; 
+    map<int,vector<int>* >::iterator ite = this->ootsViewMembers.find(sofaXmiId);
+    if (ite == ootsViewMembers.end() ) {
+      memberList = new vector<int>;
+      ootsViewMembers[sofaXmiId] = memberList;
+    } else {
+      memberList = ite->second;
+    }
+    memberList->push_back(memberXmiId);
+  }
+  
+  /**
+   * Gets a List of xmi:id's (Strings) of all out-of-typesystem XMI elements
+   * that are members of the view with the given id.
+   * @param sofaXmiId xmi:id of a Sofa
+   * @return List of xmi:id's of members of the view for the given Sofa.
+   */
+  void getOutOfTypeSystemViewMembers(int sofaXmiId, vector<int>& tofill) {
+    map<int, vector<int> *>::iterator ite = this->ootsViewMembers.find(sofaXmiId); 
+    vector<int> * memberList = NULL;
+    if (ite != ootsViewMembers.end()) {
+      memberList = ite->second;
+      for (size_t i=0;i < memberList->size();i++) {
+        tofill.push_back(memberList->at(i));
+      }
+    }
+
+  }
+  
+  /**
+   * Records an out-of-typesystem attribute that belongs to an in-typesystem FS.
+   * This will be added to the attributes when that FS is reserialized.
+   * @param addr CAS address of the FS 
+   * @param featName name of the feature
+   * @param featVal value of the feature, as a string
+   */
+  void addOutOfTypeSystemAttribute(int addr, string featName, string featVal) {
+    map<int, OotsElementData*>::iterator ite = this->ootsFeatures.find(addr);
+    OotsElementData * oed = NULL;
+    if (ite != ootsFeatures.end() )
+      oed = ite->second;
+    if (oed == NULL) {
+      oed = new OotsElementData();
+      this->ootsFeatures[addr] = oed;
+    }
+    oed->attributes.push_back(new XmlAttribute(featName, featVal));
+  }  
+
+  void addOutOfTypeSystemAttribute(int addr, UnicodeString& featName, 
+    UnicodeString & featVal) {
+      //cout << "addOotsAttribute " << featName << "=" << featVal << endl;
+      addOutOfTypeSystemAttribute(addr, ( (UnicodeStringRef)featName).asUTF8(),
+        ( (UnicodeStringRef)featVal).asUTF8());
+  }
+
+  /**
+   * Records out-of-typesystem child elements that belong to an in-typesystem FS.
+   * These will be added to the child elements when that FS is reserialized.
+   * @param addr CAS address of the FS 
+   * @param featName name of the feature (element tag name)
+   * @param featVal values of the feature, as a List of strings
+   */
+    void addOutOfTypeSystemChildElements(int addr, string featName, vector<string> featVals) {
+      map<int, OotsElementData*>::iterator ite = this->ootsFeatures.find(addr);
+      OotsElementData * oed = NULL;
+      if (ite != ootsFeatures.end() )
+        oed = ite->second;
+      if (oed == NULL) {
+        oed = new OotsElementData();
+        this->ootsFeatures[addr] = oed;
+      } 
+
+      map<string, vector<string>*>::iterator ite2 = oed->childElements.find(featName);
+      vector<string> * pVals = NULL;
+      if (ite2 ==	oed->childElements.end() ) {
+        pVals = new vector<string>;
+        oed->childElements[featName] = pVals;
+      } else {
+        pVals = ite2->second;
+      }
+
+      for (size_t i = 0; i < featVals.size();i++) {
+        pVals->push_back(featVals.at(i));
+      }
+
+    }  
+  
+  /**
+   * Gets information about out-of-typesystem features that belong to an
+   * in-typesystem FS.
+   * @param addr CAS address of the FS
+   * @return object containing information about out-of-typesystem features
+   *   (both attributes and child elements)
+   */
+  OotsElementData * getOutOfTypeSystemFeatures(int addr) {
+	  map<int, OotsElementData*>::iterator ite = this->ootsFeatures.find(addr);
+	  if (ite != this->ootsFeatures.end())
+		  return ite->second;
+      else return NULL; 
+  }
+  
+  /**
+   * Get all FS Addresses that have been added to the id map.
+   * @return an array containing all the FS addresses
+   */
+  void getAllFsAddressesInIdMap( vector<int> & tofill) {    
+	  map<int,int>::iterator ite;
+	  for (ite = this->fsAddrToXmiIdMap.begin(); ite != fsAddrToXmiIdMap.end();ite++) {
+		  tofill.push_back(ite->first);
+	  }
+  }  
+  
+  /**
+   * Gets information about out-of-typesystem array elements.
+   * @param addr the CAS address of an FSArray
+   * @return a List of {@link XmiArrayElement} objects, each of which
+   *   holds the index and xmi:id of an array element that is a
+   *   reference to an out-of-typesystem FS.
+   */
+  vector<XmiArrayElement*> * getOutOfTypeSystemArrayElements(int addr) {
+	  map<int, vector<XmiArrayElement*>*>::iterator ite=this->ootsArrayElements.find(addr);
+      if (ite != ootsArrayElements.end()) 
+		  return ite->second;
+	  else return NULL;
+  }
+  
+
+  /**
+   * Records an out-of-typesystem array element in the XmiSerializationSharedData.
+   * @param addr CAS address of FSArray
+   * @param index index into array 
+   * @param xmiId xmi:id of the out-of-typesystem element that is the value at the given index
+   */
+  void addOutOfTypeSystemArrayElement(int addr, int index, int xmiId) {
+    map<int, vector<XmiArrayElement*>* >::iterator ite = this->ootsArrayElements.find(addr);
+    vector<XmiArrayElement*> * oed = NULL;
+    if (ite != ootsArrayElements.end() )
+      oed  = ite->second;
+    else {
+      oed = new vector<XmiArrayElement*>;
+      this->ootsArrayElements[addr] = oed;
+    }
+    oed->push_back(new XmiArrayElement(index, xmiId));
+  }
+
+
+  void clearIdMap() {
+      fsAddrToXmiIdMap.clear();
+      xmiIdToFsAddrMap.clear();
+      maxXmiId = 0;
+  }
+
+  void print() {
+    map<int,OotsElementData *>::iterator ite;
+    for (size_t i=0; i < ootsFs.size() ;i++ ) {
+       OotsElementData * oed = ootsFs.at(i);
+       cout << "**OotsFS " << i << oed->elementName->qualifiedName << endl;
+       cout << "NUM CHILDELEMENTS " << oed->childElements.size() << endl;
+       for (size_t i=0; i < oed->attributes.size();i++) {
+         cout << oed->attributes.at(i)->name << " " << oed->attributes.at(i)->value << endl;
+       }    
+    }
+  }
+
+  /**
+   * For debugging purposes only.
+   */
+  
+  /**
+  string toString() {
+    
+    stringstream str; 
+ 
+    int[] keys = fsAddrToXmiIdMap;
+    for (int i = 0; i < keys.length; i++) {
+      buf.append(keys[i]).append(": ").append(fsAddrToXmiIdMap.get(keys[i])).append('\n');
+    }
+    return str.str();;
+  }**/
+
+};
+
+}
+
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif

Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/xmishareddata.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp?view=auto&rev=528573
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp Fri Apr 13 11:16:39 2007
@@ -0,0 +1,167 @@
+#ifndef UIMA_XMIWRITER_HPP
+#define UIMA_XMIWRITER_HPP
+/** \file xmiwriter.hpp .
+-----------------------------------------------------------------------------
+
+
+
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description:
+
+-----------------------------------------------------------------------------
+
+   \brief Used to output the CAS in XMI format
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp"
+
+#include <iostream>
+#include <vector>
+#include <set>
+#include <map>
+
+#include "uima/featurestructure.hpp"
+#include "uima/caswriter_abase.hpp"
+#include "uima/lowlevel_typedefs.hpp"
+#include "uima/typesystem.hpp"
+#include "uima/xmishareddata.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+  class CAS;
+  namespace internal {
+    class CASImpl;
+  }
+  namespace lowlevel {
+    class IndexABase;
+    class FSHeap;
+    class TypeSystem;
+  }
+}
+
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+
+/**
+ * This file contains the XmiWriter class used 
+ * to output the CAS in XMI format.
+ */
+
+namespace uima {
+
+
+  class UIMA_LINK_IMPORTSPEC XmiWriter : public XMLWriterABase {
+  private:
+    Type iv_stringType;
+    Type iv_integerType;
+    Type iv_floatType;
+    Type iv_byteType;
+    Type iv_booleanType;
+    Type iv_shortType;
+    Type iv_longType;
+    Type iv_doubleType;
+    Type iv_arrayType;
+    Type iv_intArrayType;
+    Type iv_floatArrayType;
+    Type iv_stringArrayType;
+    Type iv_byteArrayType;
+    Type iv_booleanArrayType;
+    Type iv_shortArrayType;
+    Type iv_longArrayType;
+    Type iv_doubleArrayType;
+
+    Type iv_sofaType;
+    bool isBCCas;
+    map<int, vector<int>*> enqueuedFS;
+    int sofa;
+
+    void writeFeatureValue(ostream & os, FeatureStructure const & fs, Feature const & f);
+    void writeFSFlat(ostream & os, FeatureStructure const & fs, vector<int>* indexInfo);
+    void findReferencedFSs(FeatureStructure const & fs, bool check=true);
+    bool isReferenceType(Type const & t) const;
+    bool enqueueIndexed(FeatureStructure const &fs, int sofa);
+    bool enqueueUnindexed(FeatureStructure const &fs);
+    bool enqueueUnindexed(int id);
+    void initTypeAndNamespaceMappings();
+    void writeViews(ostream & os, CAS const & crCAS);
+    void writeView(ostream & os,int sofaXmiId, vector<lowlevel::TyFS>& members);
+    XmlElementName * uimaTypeName2XmiElementName(UnicodeStringRef & uimaTypeName);
+    int getXmiId(int addr);
+    void writeArray(ostream & os, FeatureStructure const & array, char const * tag, int xmiid);
+    void writeBooleanArray(ostream & os, BooleanArrayFS const & array, char const * tag, int xmiid);
+    void writeStringArray(ostream & os, StringArrayFS const & array, char const * tag, int xmiid);
+    string arrayToString(FeatureStructure const & fs, char const * tag);
+    string listToString(FeatureStructure const & fs, char const * tag);
+    void enqueueIncoming();
+    void serializeOutOfTypeSystemElements(ostream & os);
+    void enqueueFSListElements(FeatureStructure const & fs);
+    vector<XmlElementName*> xmiTypeNames;  // array, indexed by type code, 
+                                           // giving XMI names for each type
+    map<string, string> nsUriToPrefixMap;
+    set<string> nsPrefixesUsed;
+    XmiSerializationSharedData * sharedData;
+    
+    static char const *  XMI_NS_URI;
+    static char const *  XMI_NS_PREFIX;
+    static char const *  DEFAULT_NAMESPACE_URI;
+    static char const *  XSI_NS_URI;
+    static char const *  XMI_TAG_LOCAL_NAME;
+    static char const *  XMI_TAG_QNAME;
+    static char const *  INDEXED_ATTR_NAME;
+    static char const *  ID_ATTR_NAME;
+    static char const *  XMI_VERSION_LOCAL_NAME;
+    static char const *  XMI_VERSION_QNAME;
+    static char const *  XMI_VERSION_VALUE;
+
+  public:
+    XmiWriter(CAS const & crCAS, bool bAddDocBuffer);
+    XmiWriter(CAS const & crCAS, bool bAddDocBuffer, XmiSerializationSharedData * );
+    ~XmiWriter();
+
+    virtual void write(ostream& os);
+  };
+
+}
+
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+
+#endif

Propchange: incubator/uima/uimacpp/trunk/src/cas/uima/xmiwriter.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp?view=auto&rev=528573
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp Fri Apr 13 11:16:39 2007
@@ -0,0 +1,227 @@
+/** \file xmideserializer.cpp .
+-----------------------------------------------------------------------------
+
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description:
+
+-----------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+#include "uima/pragmas.hpp"
+#include <memory>
+
+#include <xercesc/sax2/XMLReaderFactory.hpp>
+#include <xercesc/sax2/SAX2XMLReader.hpp>
+#include <xercesc/sax2/DefaultHandler.hpp>
+
+
+#include "uima/xmlerror_handler.hpp"
+#include "uima/xmideserializer.hpp"
+#include "uima/xmideserializer_handler.hpp"
+
+#include "uima/arrayfs.hpp"
+#include "uima/lowlevel_indexrepository.hpp"
+#include "uima/lowlevel_indexiterator.hpp"
+#include "uima/internal_casimpl.hpp"
+#include "uima/internal_fspromoter.hpp"
+#include "uima/fsindexrepository.hpp"
+#include "uima/annotator_context.hpp"
+
+#include "uima/msg.h"
+#include "uima/resmgr.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+
+  XmiDeserializer::XmiDeserializer() {}
+
+  XmiDeserializer::~XmiDeserializer() {}
+
+  void XmiDeserializer::deserialize(char const * xmiFilename, CAS & cas) {
+
+    LocalFileInputSource fileIS (XMLString::transcode(xmiFilename));
+    XmiDeserializer::deserialize(fileIS, cas);
+
+  }
+
+  void XmiDeserializer::deserialize(UnicodeString & xmiFilename, CAS & cas) {
+    char buff[1024];
+    xmiFilename.extract(0, xmiFilename.length(), buff);
+    LocalFileInputSource fileIS (XMLString::transcode(buff));
+    XmiDeserializer::deserialize(fileIS, cas);
+  }
+
+  void XmiDeserializer::deserialize(InputSource const & crInputSource, CAS & cas) {
+    // Create a SAX2 parser object.
+    SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
+
+    //register content handler
+    XmiDeserializerHandler * contentHandler = new XmiDeserializerHandler(cas, NULL);
+    parser->setContentHandler(contentHandler);
+
+    //register error handler
+    XMLErrorHandler* errorHandler = new XMLErrorHandler();
+    parser->setErrorHandler(errorHandler);
+
+    // Parse the XML document.
+    // Document content sent to registered ContentHandler instance.
+    try {
+      parser->parse(crInputSource);
+    } catch (const XMLException& e) {
+      char* message = XMLString::transcode(e.getMessage());
+      cerr << "XMLException message is: \n"
+      << message << "\n";
+
+      ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam((UChar const *) e.getMessage() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      throw exc;
+    }
+    catch (const SAXParseException& e) {
+      char* message = XMLString::transcode(e.getMessage());
+      cerr << "SaxParseException message is: \n"
+      << message << "\n";
+      ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam((UChar const *) e.getMessage() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      throw exc;
+    }
+
+    // Delete the parser instance and handlers
+    delete contentHandler;
+    delete errorHandler;
+    delete parser;
+  }
+
+
+  void XmiDeserializer::deserialize(InputSource const & crInputSource, 
+								CAS & cas,
+								XmiSerializationSharedData & sharedData) {
+    // Create a SAX2 parser object.
+    SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
+
+    //register content handler
+    XmiDeserializerHandler * contentHandler = new XmiDeserializerHandler(cas, &sharedData);
+    parser->setContentHandler(contentHandler);
+
+    //register error handler
+    XMLErrorHandler* errorHandler = new XMLErrorHandler();
+    parser->setErrorHandler(errorHandler);
+
+    // Parse the XML document.
+    // Document content sent to registered ContentHandler instance.
+    try {
+      parser->parse(crInputSource);
+    } catch (const XMLException& e) {
+      char* message = XMLString::transcode(e.getMessage());
+      cerr << "XMLException message is: \n"
+      << message << "\n";
+
+      ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam((UChar const *) e.getMessage() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      throw exc;
+    }
+    catch (const SAXParseException& e) {
+      char* message = XMLString::transcode(e.getMessage());
+      cerr << "SaxParseException message is: \n"
+      << message << "\n";
+      ErrorInfo errInfo;
+      errInfo.setErrorId((TyErrorId)UIMA_ERR_RESOURCE_CORRUPTED);
+      ErrorMessage msg(UIMA_MSG_ID_EXC_XML_SAXPARSE_FATALERROR);
+      assertWithMsg(sizeof(XMLCh) == sizeof(UChar), "Port required");
+      msg.addParam((UChar const *) e.getMessage() );
+      msg.addParam( 0 );
+      msg.addParam( 0 );
+      errInfo.setMessage(msg);
+      errInfo.setSeverity(ErrorInfo::unrecoverable);
+      ExcIllFormedInputError exc(errInfo);
+      throw exc;
+    }
+
+    // Delete the parser instance and handlers
+    delete contentHandler;
+    delete errorHandler;
+    delete parser;
+  }
+
+ void XmiDeserializer::deserialize(char const * xmiFilename, 
+									CAS & cas,
+									XmiSerializationSharedData & sharedData) {
+
+    LocalFileInputSource fileIS (XMLString::transcode(xmiFilename));
+    XmiDeserializer::deserialize(fileIS, cas, sharedData);
+
+ }
+
+ void XmiDeserializer::deserialize(UnicodeString & xmiFilename, 
+									CAS & cas,
+									XmiSerializationSharedData & sharedData) {
+    char buff[1024];
+    xmiFilename.extract(0, xmiFilename.length(), buff);
+    LocalFileInputSource fileIS (XMLString::transcode(buff));
+    XmiDeserializer::deserialize(fileIS, cas, sharedData);
+  }
+}
+
+
+
+

Propchange: incubator/uima/uimacpp/trunk/src/cas/xmideserializer.cpp
------------------------------------------------------------------------------
    svn:eol-style = native