You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2010/08/01 06:03:45 UTC

svn commit: r981137 - in /incubator/oodt/trunk: CHANGES.txt metadata/src/main/cpp/Makefile metadata/src/main/cpp/Metadata.cpp metadata/src/main/cpp/Metadata.h metadata/src/main/cpp/testMetadata.cpp metadata/src/main/cpp/util/

Author: mattmann
Date: Sun Aug  1 04:03:45 2010
New Revision: 981137

URL: http://svn.apache.org/viewvc?rev=981137&view=rev
Log:
- fix for OODT-19 Metadata should not use a GPL-licensed XML parser

Removed:
    incubator/oodt/trunk/metadata/src/main/cpp/util/
Modified:
    incubator/oodt/trunk/CHANGES.txt
    incubator/oodt/trunk/metadata/src/main/cpp/Makefile
    incubator/oodt/trunk/metadata/src/main/cpp/Metadata.cpp
    incubator/oodt/trunk/metadata/src/main/cpp/Metadata.h
    incubator/oodt/trunk/metadata/src/main/cpp/testMetadata.cpp

Modified: incubator/oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/CHANGES.txt?rev=981137&r1=981136&r2=981137&view=diff
==============================================================================
--- incubator/oodt/trunk/CHANGES.txt (original)
+++ incubator/oodt/trunk/CHANGES.txt Sun Aug  1 04:03:45 2010
@@ -5,6 +5,8 @@ Apache OODT Change Log
 Release 0.1-incubating - Current Development
 --------------------------------------------
 
+* OODT-19 Metadata should not use a GPL-licensed XML parser (mattmann)
+
 * OODT-7 Curator adds escaped sequenced spaces when reading extractorBinPath 
   tag from extractor config files (joshuaga via mattmann)
 

Modified: incubator/oodt/trunk/metadata/src/main/cpp/Makefile
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/main/cpp/Makefile?rev=981137&r1=981136&r2=981137&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/main/cpp/Makefile (original)
+++ incubator/oodt/trunk/metadata/src/main/cpp/Makefile Sun Aug  1 04:03:45 2010
@@ -20,18 +20,15 @@ CC=gcc
 LIBRARIES = -lxerces-c -lstdc++
 INCLUDES = -I/usr/include/xercesc/
 
-all:    XMLUtils.o metadata.o
+all:    metadata.o
 
 # clean out the dross
 clean:
 		rm *.o test
         
-metadata.o: Metadata.h XStr.h ./util/xml/XMLUtils.h
+metadata.o: Metadata.h XStr.h
 		$(CC) -c Metadata.cpp $(INCLUDES)
 
-XMLUtils.o: ./util/xml/XMLUtils.h
-		$(CC) -c ./util/xml/XMLUtils.cpp $(INCLUDES)
-
-test: XMLUtils.o metadata.o
-		$(CC) -g metadata.o XMLUtils.o testMetadata.cpp $(LIBRARIES) -o test
+test: metadata.o
+		$(CC) -g metadata.o testMetadata.cpp $(LIBRARIES) -o test
 		

Modified: incubator/oodt/trunk/metadata/src/main/cpp/Metadata.cpp
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/main/cpp/Metadata.cpp?rev=981137&r1=981136&r2=981137&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/main/cpp/Metadata.cpp (original)
+++ incubator/oodt/trunk/metadata/src/main/cpp/Metadata.cpp Sun Aug  1 04:03:45 2010
@@ -20,7 +20,6 @@
 
 #include "Metadata.h"
 #include "XStr.h"
-#include "./util/xml/XMLUtils.h"
 #include <vector>
 #include <map>
 #include <string>
@@ -42,11 +41,6 @@ XERCES_CPP_NAMESPACE_USE
 //STD imports
 using namespace std;
 
-//XML Utils imports
-using namespace xmlutils;
-
-
-
 namespace cas
 {
 
@@ -71,7 +65,6 @@ Metadata::Metadata(DOMDocument *doc)
    }
    
    XMLCh *keyValStr = XMLString::transcode("keyval");
-   
    DOMNodeList *keyValElems = metadataRootElem->getElementsByTagName(keyValStr);
    
    const XMLSize_t nodeCount = keyValElems->getLength();
@@ -121,7 +114,7 @@ void Metadata::read(DOMElement *elem, co
 	DOMNodeList *valueNodes = elem->getElementsByTagName(tagName);
 	
 	DOMNode* valElem = valueNodes->item(0);
-	value = getNodeText(valElem);
+	value = getSimpleNodeText(valElem);
 }
  
 
@@ -131,7 +124,7 @@ void Metadata::readMany(DOMElement *elem
 	
     for(int i=0; i < valueNodes->getLength(); i++){
     	  DOMNode *valElem = valueNodes->item(i);
-    	  string value = getNodeText(valElem);
+    	  string value = getSimpleNodeText(valElem);
     	  values.push_back(value);
     }
 }
@@ -206,6 +199,20 @@ const vector<string>& Metadata::getAllMe
     		
 }
 
+string Metadata::getSimpleNodeText(DOMNode* node){
+    string nodeTxt = "";
+    DOMNodeList *children = node->getChildNodes();
+    for(int i=0; i < children->getLength(); i++){
+      DOMNode *n = children->item(i);
+      if(n->getNodeType() == DOMNode::TEXT_NODE){
+         const XMLCh *xmlText = n->getNodeValue();
+         nodeTxt+=XMLString::transcode(xmlText);
+      }    
+    }
+
+   return nodeTxt;
+}
+
 DOMDocument* Metadata::toXML(void){
     // Initialize the XML4C2 system.
     try
@@ -231,7 +238,6 @@ DOMDocument* Metadata::toXML(void){
        {
            try
            {
-	     //DOMDocumentType* pDoctype = impl->createDocumentType( NULL, NULL, NULL );
                DOMDocument* doc = impl->createDocument(
                            // FIXME: change namespace URI?
                            X("http://oodt.jpl.nasa.gov/1.0/cas"),                    // root element namespace URI.

Modified: incubator/oodt/trunk/metadata/src/main/cpp/Metadata.h
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/main/cpp/Metadata.h?rev=981137&r1=981136&r2=981137&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/main/cpp/Metadata.h (original)
+++ incubator/oodt/trunk/metadata/src/main/cpp/Metadata.h Sun Aug  1 04:03:45 2010
@@ -168,6 +168,7 @@ private:
     
     void read(DOMElement *elem, const string& key, string& value);
     void readMany(DOMElement *elem, const string& key, vector<string>& values);
+    string getSimpleNodeText(DOMNode *node);
     
 };
 

Modified: incubator/oodt/trunk/metadata/src/main/cpp/testMetadata.cpp
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/main/cpp/testMetadata.cpp?rev=981137&r1=981136&r2=981137&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/main/cpp/testMetadata.cpp (original)
+++ incubator/oodt/trunk/metadata/src/main/cpp/testMetadata.cpp Sun Aug  1 04:03:45 2010
@@ -22,7 +22,6 @@
 #include <xercesc/dom/DOM.hpp>
 #include <xercesc/dom/DOMImplementation.hpp>
 #include <xercesc/dom/DOMImplementationLS.hpp>
-#include <xercesc/dom/DOMWriter.hpp>
 #include <xercesc/framework/StdOutFormatTarget.hpp>
 #include<xercesc/parsers/XercesDOMParser.hpp>
 
@@ -138,15 +137,22 @@ int main(void){
 	cout << "XML is: " << endl;
     DOMDocument* doc = metadata.toXML();
 	XMLCh tempStr[100];
+ 
+
 	XMLString::transcode("LS", tempStr, 99);
 	DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
-	DOMWriter         *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
-	if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
-	  theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
+    DOMLSSerializer* theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
+
+
+	if (theSerializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
+	  theSerializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
 
 	XMLFormatTarget *myFormTarget;
         myFormTarget = new StdOutFormatTarget();
-	theSerializer->writeNode(myFormTarget, *doc);
+    DOMLSOutput* theOutput = ((DOMImplementationLS*)impl)->createLSOutput();
+    theOutput->setByteStream(myFormTarget);
+
+	theSerializer->write((DOMNode*)doc, theOutput);
 	
 	cout << "Now attempting to parse cas xml document: data/sample.met.xml" << endl;
 	
@@ -170,7 +176,7 @@ int main(void){
     cout << "Outputting XML from CAS Metadata " << endl;
         
     DOMDocument *newDoc = newMetadata.toXML();
-    theSerializer->writeNode(myFormTarget, *doc);
+    theSerializer->write((DOMNode*)doc, theOutput);
     
 	return 1;