Changeset 1006
- Timestamp:
- 11/07/08 22:54:57 (2 months ago)
- Files:
-
- branches/dutfoy/devel/doc/configure.ac (modified) (1 diff)
- branches/dutfoy/devel/doc/src/UserManual/Statistics_UserManual.tex (modified) (2 diffs)
- branches/dutfoy/devel/gui/configure.ac (modified) (3 diffs)
- branches/dutfoy/devel/lib/src/Base/Common/Path.cxx (modified) (2 diffs)
- branches/dutfoy/devel/lib/src/Base/Common/Path.hxx (modified) (1 diff)
- branches/dutfoy/devel/lib/src/Base/Common/XMLToolbox.cxx (modified) (7 diffs)
- branches/dutfoy/devel/lib/src/Base/Common/XMLToolbox.hxx (modified) (3 diffs)
- branches/dutfoy/devel/lib/src/Base/Func/WrapperFile.cxx (modified) (22 diffs)
- branches/dutfoy/devel/lib/src/Base/Func/WrapperFile.hxx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dutfoy/devel/doc/configure.ac
r1000 r1006 118 118 #]) 119 119 120 test "x$WITH_PDFLATEX" = x1 && sum_pdflatex=OK || sum_pdflatex="no * (MANDATORY)" 121 test "x$WITH_MAKEINDEX" = x1 && sum_makeindex=OK || sum_makeindex="no * (MANDATORY)" 122 test "x$WITH_BIBTEX" = x1 && sum_bibtex=OK || sum_bibtex="no * (MANDATORY)" 123 120 124 cat <<EOT > summary 121 125 (doc) 126 127 Debug level is ${DEBUG_LEVEL} 128 129 Support for is 130 ----------------------------- 131 pdflatex ${sum_pdflatex} 132 makeindex ${sum_makeindex} 133 bibtex ${sum_bibtex} 122 134 EOT 123 135 cat summary branches/dutfoy/devel/doc/src/UserManual/Statistics_UserManual.tex
r906 r1006 343 343 \item[Arguments :] \strut 344 344 \begin{description} 345 \item $sample1$ : a NumericalSample, of dimension $n \geq 2$ 346 \item $sample2$ : a NumericalSample, of dimension =1 347 \end{description} 348 \item[Value :] a NumericalPoint, the PCC (Partial Correlation Coefficient) coefficients evaluated between the $sample2$ and each coordinate of $sample1$ 349 \end{description} 350 \bigskip 351 352 \item $PRCC$ 353 \begin{description} 354 \item[Usage :] $PRCC(sample1, sample2)$ 355 \item[Arguments :] \strut 356 \begin{description} 357 \item $sample1$ : a NumericalSample, of dimension $n \geq 2$ 358 \item $sample2$ : a NumericalSample, of dimension =1 359 \end{description} 360 \item[Value :] a NumericalPoint, the PRCC (Partial Rank Correlation Coefficient) coefficients evaluated between the $sample2$ and each coordinate of $sample1$ (based on the rank values) 361 \end{description} 362 \bigskip 363 364 \item $PearsonCorrelation$ 365 \begin{description} 366 \item[Usage :] $PearsonCorrelation(sample1, sample2)$ 367 \item[Arguments :] \strut 368 \begin{description} 369 \item $sample1$ : a NumericalSample, of dimension = 1 370 \item $sample2$ : a NumericalSample, of dimension = 1 371 \end{description} 372 \item[Value :] a real value, the Pearson Correlation coefficient evaluated between the $sample2$ and $sample1$ 373 \end{description} 374 \bigskip 375 376 \item $SRC$ 377 \begin{description} 378 \item[Usage :] $SRC(sample1, sample2)$ 379 \item[Arguments :] \strut 380 \begin{description} 345 381 \item $sample1$ : a NumericalSample, of dimension $n \geq 1$ 346 \item $sample2$ : a NumericalSample, of dimension = 1347 \end{description} 348 \item[Value :] a NumericalPoint, the PCC (partial Pearson Correlation Coefficient)coefficients evaluated between the $sample2$ and each coordinate of $sample1$349 \end{description} 350 \bigskip 351 352 \item $ PRCC$382 \item $sample2$ : a NumericalSample, of dimension = 1 383 \end{description} 384 \item[Value :] a NumericalPoint, the SRC (Standard Regression Coefficient) coefficients evaluated between the $sample2$ and each coordinate of $sample1$ 385 \end{description} 386 \bigskip 387 388 \item $SRRC$ 353 389 \begin{description} 354 390 \item[Usage :] $PRCC(sample1, sample2)$ … … 356 392 \begin{description} 357 393 \item $sample1$ : a NumericalSample, of dimension $n \geq 1$ 358 \item $sample2$ : a NumericalSample, of dimension = 1359 \end{description} 360 \item[Value :] a NumericalPoint, the PRCC (Pearson Rank Correlation Coefficient)coefficients evaluated between the $sample2$ and each coordinate of $sample1$ (based on the rank values)361 \end{description} 362 \bigskip 363 364 \item $ PearsonCorrelation$365 \begin{description} 366 \item[Usage :] $ PearsonCorrelation(sample1, sample2)$394 \item $sample2$ : a NumericalSample, of dimension = 1 395 \end{description} 396 \item[Value :] a NumericalPoint, the SRRC (Standard Rank Regression Coefficient)coefficients evaluated between the $sample2$ and each coordinate of $sample1$ (based on the rank values) 397 \end{description} 398 \bigskip 399 400 \item $SpearmanCorrelation$ 401 \begin{description} 402 \item[Usage :] $SpearmanCorrelation(sample1, sample2)$ 367 403 \item[Arguments :] \strut 368 404 \begin{description} 369 405 \item $sample1$ : a NumericalSample, of dimension = 1 370 \item $sample2$ : a NumericalSample, of dimension =1 371 \end{description} 372 \item[Value :] a real value, the Pearson Correlation coefficient evaluated between the $sample2$ and $sample1$ 373 \end{description} 374 \bigskip 375 376 \item $SRC$ 377 \begin{description} 378 \item[Usage :] $SRC(sample1, sample2)$ 379 \item[Arguments :] \strut 380 \begin{description} 381 \item $sample1$ : a NumericalSample, of dimension $n \geq 1$ 382 \item $sample2$ : a NumericalSample, of dimension =1 383 \end{description} 384 \item[Value :] a NumericalPoint, the SRC (Standard Regression Coefficient) coefficients evaluated between the $sample2$ and each coordinate of $sample1$ 385 \end{description} 386 \bigskip 387 388 \item $SRCC$ 389 \begin{description} 390 \item[Usage :] $PRCC(sample1, sample2)$ 391 \item[Arguments :] \strut 392 \begin{description} 393 \item $sample1$ : a NumericalSample, of dimension $n \geq 1$ 394 \item $sample2$ : a NumericalSample, of dimension =1 395 \end{description} 396 \item[Value :] a NumericalPoint, the SRCC (Standard Rank Regression Coefficient)coefficients evaluated between the $sample2$ and each coordinate of $sample1$ (based on the rank values) 397 \end{description} 398 \bigskip 399 400 \item $SpearmanCorrelation$ 401 \begin{description} 402 \item[Usage :] $SpearmanCorrelation(sample1, sample2)$ 403 \item[Arguments :] \strut 404 \begin{description} 405 \item $sample1$ : a NumericalSample, of dimension =1 406 \item $sample2$ : a NumericalSample, of dimension =1 406 \item $sample2$ : a NumericalSample, of dimension = 1 407 407 \end{description} 408 408 \item[Value :] a real value, the Spearman Correlation coefficient evaluated between the $sample2$ and $sample1$ (based on the rank values) branches/dutfoy/devel/gui/configure.ac
r1000 r1006 100 100 OT_CHECK_DOT 101 101 102 # Check for BOOST103 OT_CHECK_BOOST104 105 102 # Get object default name 106 103 OT_GET_OBJECT_DEFAULT_NAME … … 137 134 test "x$WITH_DOXYGEN" = x1 && sum_doxygen=OK || sum_doxygen="no * (optional)" 138 135 test "x$WITH_DOT" = x1 && sum_dot=OK || sum_dot="no * (optional)" 139 test "x$WITH_BOOST" = x1 && sum_boost=OK || sum_dot="no * (MANDATORY)"140 136 test "x$have_qt" = xyes && sum_qt=OK || sum_qt="no * (MANDATORY)" 141 137 … … 155 151 Doxygen ${sum_doxygen} 156 152 dot ${sum_dot} 157 BOOST ${sum_boost}158 153 Qt ${sum_qt} 159 154 EOT branches/dutfoy/devel/lib/src/Base/Common/Path.cxx
r969 r1006 87 87 } 88 88 89 /* The directory where installed wrappers and DTD are */ 90 FileName Path::GetStandardWrapperDirectory() 91 { 92 FileName directory = DATA_PATH; 93 directory += Path::PrefixWrapperSubdirectory_; 94 return directory; 95 } 89 96 90 97 … … 134 141 135 142 // ... search in ${prefix}/wrappers 136 FileName directory = DATA_PATH; 137 directory += Path::PrefixWrapperSubdirectory_; 143 FileName directory = Path::GetStandardWrapperDirectory(); 138 144 directoryList.push_back(directory); 139 145 branches/dutfoy/devel/lib/src/Base/Common/Path.hxx
r831 r1006 52 52 53 53 typedef std::vector<FileName> DirectoryList; 54 55 /** The directory where installed wrappers and DTD are */ 56 static FileName GetStandardWrapperDirectory(); 54 57 55 58 /** branches/dutfoy/devel/lib/src/Base/Common/XMLToolbox.cxx
r1000 r1006 93 93 } 94 94 95 Bool XMLDoc::hasDTD() const 96 { 97 xmlDtdPtr dtd = xmlGetIntSubset( doc_ ); 98 return (dtd != NULL); 99 } 100 101 Bool XMLDoc::validate() const 102 { 103 xmlValidCtxtPtr validCtxt = xmlNewValidCtxt(); 104 int ok = xmlValidateDocument( validCtxt, doc_ ); 105 xmlFreeValidCtxt( validCtxt ); 106 return (ok == 1); 107 } 108 109 Bool XMLDoc::validate(const String & name, const FileName & dtd) const 110 { 111 XML::xmlString aName = XML::xmlString( name.begin(), name.end() ); 112 XML::xmlString aDtd = XML::xmlString( dtd.begin(), dtd.end() ); 113 xmlDtdPtr theDTD = xmlNewDtd( doc_, aName.c_str(), NULL, aDtd.c_str() ); 114 xmlValidCtxtPtr validCtxt = xmlNewValidCtxt(); 115 int ok = xmlValidateDtd( validCtxt, doc_, theDTD ); 116 xmlFreeValidCtxt( validCtxt ); 117 xmlFreeDtd( theDTD ); 118 return (ok == 1); 119 } 120 121 95 122 96 123 String XML::ToString(const xmlString & st) … … 133 160 134 161 135 String XML::GetAttributeByName(const Node & parent, const String & name)162 String XML::GetAttributeByName(const Node & node, const String & name) 136 163 { 137 164 String attrVal; 138 if ( parent) {165 if (node) { 139 166 xmlString aName = xmlString( name.begin(), name.end() ); 140 if ( xmlHasProp( parent, aName.c_str() ) ) {141 xmlString val = xmlGetProp( parent, aName.c_str() );167 if ( xmlHasProp( node, aName.c_str() ) ) { 168 xmlString val = xmlGetProp(node, aName.c_str() ); 142 169 attrVal = String(val.begin(), val.end()); 143 170 } … … 147 174 148 175 149 void XML::SetAttribute(const Node & parent, const String & attribute, const String & value)150 { 151 if ( parent) {176 void XML::SetAttribute(const Node & node, const String & attribute, const String & value) 177 { 178 if (node) { 152 179 xmlString aAttr = xmlString( attribute.begin(), attribute.end() ); 153 180 xmlString aValue = xmlString( value.begin(), value.end() ); 154 xmlNewProp( parent, aAttr.c_str(), aValue.c_str() );155 } 156 } 157 158 159 XML::Node XML::FindElementByName(const Node & parent, const String & name)181 xmlNewProp( node, aAttr.c_str(), aValue.c_str() ); 182 } 183 } 184 185 186 XML::Node XML::FindElementByName(const Node & node, const String & name) 160 187 { 161 188 Node cur = NULL; 162 if ( parent) {163 for(cur = parent->children; cur; cur = cur->next) {189 if (node) { 190 for(cur = node->children; cur; cur = cur->next) { 164 191 if (IsElement(cur, name)) { 165 192 break; … … 172 199 173 200 174 String XML::GetNodeValue(const Node & parent)201 String XML::GetNodeValue(const Node & node) 175 202 { 176 203 String value; 177 204 Node cur = NULL; 178 if ( parent) {179 for(cur = parent->children; cur; cur = cur->next) {205 if (node) { 206 for(cur = node->children; cur; cur = cur->next) { 180 207 if (IsText(cur)) { 181 208 xmlString val = cur->content; … … 189 216 190 217 191 String XML::GetNodeName(const Node & parent)218 String XML::GetNodeName(const Node & node) 192 219 { 193 220 String name; 194 if ( parent) {195 xmlString aName = parent->name;221 if (node) { 222 xmlString aName = node->name; 196 223 name = String( aName.begin(), aName.end() ); 197 224 } … … 199 226 } 200 227 228 229 230 UnsignedLong XML::GetNodeLineNumber(const Node & node) 231 { 232 UnsignedLong lineno = 0; 233 if (node) lineno = xmlGetLineNo(node); 234 return lineno; 235 } 201 236 202 237 … … 255 290 } 256 291 292 void XML::SetDTD( const XMLDoc & doc, const String & name, const String & path ) 293 { 294 xmlString aName = xmlString( name.begin(), name.end() ); 295 xmlString aPath = xmlString( path.begin(), path.end() ); 296 xmlCreateIntSubset( doc, aName.c_str(), NULL, aPath.c_str() ); 297 } 257 298 258 299 branches/dutfoy/devel/lib/src/Base/Common/XMLToolbox.hxx
r1000 r1006 55 55 class XMLDoc { 56 56 xmlDocPtr doc_; 57 57 58 public: 59 58 60 XMLDoc(); 59 XMLDoc( const XMLDoc & other);60 XMLDoc( const FileName & pathToFile);61 XMLDoc( const XMLDoc & other ); 62 XMLDoc( const FileName & pathToFile ); 61 63 ~XMLDoc() throw(); 62 XMLDoc & operator =(const XMLDoc & other); 64 65 XMLDoc & operator =( const XMLDoc & other ); 66 63 67 operator xmlDocPtr(); 64 68 operator const xmlDocPtr() const; 69 65 70 void save( const FileName & fileName ) const; 71 72 Bool hasDTD() const; 73 Bool validate() const; 74 Bool validate( const String & name, const FileName & dtd ) const; 66 75 }; 67 76 … … 82 91 83 92 /** Convert XML string to basic string */ 84 static String ToString( const xmlString & st);93 static String ToString( const xmlString & st ); 85 94 86 95 /** Returns true if node 'elt' is an XML text node */ 87 static Bool IsText( const Node & elt);96 static Bool IsText( const Node & elt ); 88 97 89 98 /** Returns true if node 'elt' is an XML Element node */ 90 static Bool IsElement( const Node & elt);99 static Bool IsElement( const Node & elt ); 91 100 92 101 /** Returns true if node 'elt' is an XML element node named 'name' */ 93 static Bool IsElement( const Node & elt, const String & name);102 static Bool IsElement( const Node & elt, const String & name ); 94 103 95 104 /** Returns true if node 'elt' has a attribute named 'name' */ 96 static Bool ElementHasAttribute( const Node & elt, const String & name);105 static Bool ElementHasAttribute( const Node & elt, const String & name ); 97 106 98 /** Returns the value of the attribute named 'name' hold by node 'parent' */99 static String GetAttributeByName( const Node & parent, const String & name);107 /** Returns the value of the attribute named 'name' hold by 'node' */ 108 static String GetAttributeByName( const Node & node, const String & name ); 100 109 101 110 /** Set the attribute of a node */ 102 static void SetAttribute( const Node & parent, const String & attribute, const String & value);111 static void SetAttribute( const Node & node, const String & attribute, const String & value ); 103 112 104 113 /** Returns the child node named 'name' of node 'parent' */ 105 static Node FindElementByName( const Node & parent, const String & name);114 static Node FindElementByName( const Node & parent, const String & name ); 106 115 107 /** Returns the content of node 'parent' */108 static String GetNodeValue( const Node & parent);116 /** Returns the content of 'node' */ 117 static String GetNodeValue( const Node & node ); 109 118 110 /** Returns the name of node 'parent' */ 111 static String GetNodeName(const Node & parent); 119 /** Returns the name of 'node' */ 120 static String GetNodeName( const Node & node ); 121 122 /** Returns the line number where 'node' appears */ 123 static UnsignedLong GetNodeLineNumber( const Node & node ); 112 124 113 125 /** Create a new node */ 114 static Node NewNode( const String & name);115 static Node NewNode( const String & name, const String & value);116 static Node NewTextNode( const String & value);126 static Node NewNode( const String & name ); 127 static Node NewNode( const String & name, const String & value ); 128 static Node NewTextNode( const String & value ); 117 129 118 130 /** Link a child node to its parent */ 119 static void AddChild( const Node & parent, const Node & child);131 static void AddChild( const Node & parent, const Node & child ); 120 132 121 133 /** Get/Set the root node of an XML file */ … … 127 139 static Node GetNextNode( const Node & node ); 128 140 141 /** Set the DTD of the document */ 142 static void SetDTD( const XMLDoc & doc, const String & name, const String & path ); 143 129 144 }; /* end class XML */ 130 145 branches/dutfoy/devel/lib/src/Base/Func/WrapperFile.cxx
r1000 r1006 54 54 using Common::WrapperFileParsingException; 55 55 using Common::FileNotFoundException; 56 using Common::NotYetImplementedException; 57 using Common::InternalException; 56 58 using Common::Log; 57 59 using Common::Path; … … 60 62 #ifdef XML_SUPPORTED 61 63 const String WrapperFile::extension_ = ".xml"; 64 static const FileName DTDFileName = "wrapper.dtd"; 62 65 #else 63 66 const String WrapperFile::extension_ = ".txt"; 64 67 #endif 65 66 /* The environment variable name */67 const String WrapperFile::openturnsWrapperPathVariableName_ = "OPENTURNS_WRAPPER_PATH";68 69 /* The HOME subdirectory path */70 const String WrapperFile::homeSubdirectory_ = "/openturns/wrappers";71 72 /* The 'prefix' subdirectory path */73 const String WrapperFile::prefixSubdirectory_ = "/openturns/wrappers";74 68 75 69 … … 109 103 } 110 104 111 #if defined HAS_LIBXML2105 #ifdef XML_SUPPORTED 112 106 113 107 using Common::XMLDoc; … … 132 126 throw(WrapperFileParsingException) 133 127 { 128 Log::Debug(OSS() << "Try parsing file " << pathToFile); 129 134 130 // Load the wrapper file 135 131 XMLDoc doc( pathToFile ); 136 132 133 const FileName DTDPath = Path::GetStandardWrapperDirectory() + "/" + DTDFileName; 134 Bool ok = doc.hasDTD() ? doc.validate() : doc.validate( XMLTag_wrapper, DTDPath ); 135 if (!ok) throw WrapperFileParsingException(HERE) << "The generated wrapper does not conform to DTD"; 136 else Log::Debug( OSS() << "Wrapper file " << pathToFile << " is valid according to DTD" ); 137 137 138 // Check it is an OpenTURNS' one 138 xmlNodePtr wrapperElt = xmlDocGetRootElement( doc );139 XML::Node wrapperElt = XML::GetRootNode( doc ); 139 140 if (wrapperElt == NULL) throw WrapperFileParsingException(HERE) << "Wrapper file has no root element (" << pathToFile << ")"; 140 if ( xmlStrcmp( wrapperElt->name, REINTERPRET_CAST(const xmlChar *, XMLTag_wrapper)))141 if (! XML::IsElement( wrapperElt, XMLTag_wrapper )) 141 142 throw WrapperFileParsingException(HERE) << "Wrapper file " << pathToFile 142 << " has an invalid root element (" << wrapperElt->name<< ")"143 << " at line " << xmlGetLineNo(wrapperElt);144 145 xmlNodePtrlibraryElt = XML::FindElementByName( wrapperElt, XMLTag_library );146 xmlNodePtrlibraryPathElt = XML::FindElementByName( libraryElt, XMLTag_path );143 << " has an invalid root element (" << XML::GetNodeName( wrapperElt ) << ")" 144 << " at line " << XML::GetNodeLineNumber( wrapperElt ); 145 146 XML::Node libraryElt = XML::FindElementByName( wrapperElt, XMLTag_library ); 147 XML::Node libraryPathElt = XML::FindElementByName( libraryElt, XMLTag_path ); 147 148 String libraryPath = XML::GetNodeValue( libraryPathElt ); 148 149 if (libraryPath.empty()) throw WrapperFileParsingException(HERE) << "Library path tag not found in wrapper file " << pathToFile; … … 153 154 154 155 155 xmlNodePtrdescriptionElt = XML::FindElementByName( libraryElt, XMLTag_description );156 xmlNodePtrvariableListElt = XML::FindElementByName( descriptionElt, XMLTag_variable_list );156 XML::Node descriptionElt = XML::FindElementByName( libraryElt, XMLTag_description ); 157 XML::Node variableListElt = XML::FindElementByName( descriptionElt, XMLTag_variable_list ); 157 158 WrapperData::VariableListType variableList; 158 if ( variableListElt && variableListElt->children) {159 for ( xmlNodePtr current = variableListElt->children; current; current = current->next) {159 if (XML::IsElement(variableListElt)) { 160 for (XML::Node current = XML::GetFirstChild(variableListElt); current; current = XML::GetNextNode(current)) { 160 161 if (XML::IsElement(current, XMLTag_variable)) { 161 162 WrapperDataVariable variable; 162 163 163 xmlNodePtrcommentElt = XML::FindElementByName( current, XMLTag_comment );164 XML::Node commentElt = XML::FindElementByName( current, XMLTag_comment ); 164 165 if (commentElt) variable.comment_ = XML::GetNodeValue( commentElt ); 165 166 166 xmlNodePtrunitElt = XML::FindElementByName( current, XMLTag_unit );167 XML::Node unitElt = XML::FindElementByName( current, XMLTag_unit ); 167 168 if (unitElt) variable.unit_ = XML::GetNodeValue( unitElt ); 168 169 169 xmlNodePtrregexpElt = XML::FindElementByName( current, XMLTag_regexp );170 XML::Node regexpElt = XML::FindElementByName( current, XMLTag_regexp ); 170 171 if (regexpElt) variable.regexp_ = XML::GetNodeValue( regexpElt ); 171 172 172 xmlNodePtrformatElt = XML::FindElementByName( current, XMLTag_format );173 XML::Node formatElt = XML::FindElementByName( current, XMLTag_format ); 173 174 if (formatElt) variable.format_ = XML::GetNodeValue( formatElt ); 174 175 … … 182 183 throw WrapperFileParsingException(HERE) << "Unknown type (" << type_ 183 184 << ") for variable in wrapper file " << pathToFile 184 << " at line " << xmlGetLineNo(current);185 << " at line " << XML::GetNodeLineNumber( current ); 185 186 } 186 187 … … 193 194 throw WrapperFileParsingException(HERE) << "Unknown " << XMLTag_computed_gradient << " attribute (" << computedGradient_ 194 195 << ") for variable in wrapper file " << pathToFile 195 << " at line " << xmlGetLineNo(current);196 << " at line " << XML::GetNodeLineNumber( current ); 196 197 } 197 198 … … 213 214 214 215 WrapperFunctionDescription functionDesc; 215 xmlNodePtrfunctionElt = XML::FindElementByName( descriptionElt, XMLTag_function );216 XML::Node functionElt = XML::FindElementByName( descriptionElt, XMLTag_function ); 216 217 functionDesc.name_ = XML::GetNodeValue( functionElt ); 217 218 … … 224 225 throw WrapperFileParsingException(HERE) << "Unknown " << XMLTag_provided << " attribute (" << functionProvided_ 225 226 << ") for variable in wrapper file " << pathToFile 226 << " at line " << xmlGetLineNo(functionElt);227 << " at line " << XML::GetNodeLineNumber( functionElt ); 227 228 } 228 229 data_.setFunctionDescription( functionDesc ); … … 235 236 236 237 WrapperFunctionDescription gradientDesc; 237 xmlNodePtrgradientElt = XML::FindElementByName( descriptionElt, XMLTag_gradient );238 XML::Node gradientElt = XML::FindElementByName( descriptionElt, XMLTag_gradient ); 238 239 gradientDesc.name_ = XML::GetNodeValue( gradientElt ); 239 240 … … 246 247 throw WrapperFileParsingException(HERE) << "Unknown " << XMLTag_provided << " attribute (" << gradientProvided_ 247 248 << ") for variable in wrapper file " << pathToFile 248 << " at line " << xmlGetLineNo(gradientElt);249 << " at line " << XML::GetNodeLineNumber( gradientElt ); 249 250 } 250 251 data_.setGradientDescription( gradientDesc ); … … 257 258 258 259 WrapperFunctionDescription hessianDesc; 259 xmlNodePtrhessianElt = XML::FindElementByName( descriptionElt, XMLTag_hessian );260 XML::Node hessianElt = XML::FindElementByName( descriptionElt, XMLTag_hessian ); 260 261 hessianDesc.name_ = XML::GetNodeValue( hessianElt ); 261 262 … … 268 269 throw WrapperFileParsingException(HERE) << "Unknown " << XMLTag_provided << " attribute (" << hessianProvided_ 269 270 << ") for variable in wrapper file " << pathToFile 270 << " at line " << xmlGetLineNo(hessianElt);271 << " at line " << XML::GetNodeLineNumber( hessianElt ); 271 272 } 272 273 data_.setHessianDescription( hessianDesc ); … … 277 278 278 279 279 xmlNodePtrexternalCodeElt = XML::FindElementByName( wrapperElt, XMLTag_external_code );280 xmlNodePtrdataElt = XML::FindElementByName( externalCodeElt, XMLTag_data );280 XML::Node externalCodeElt = XML::FindElementByName( wrapperElt, XMLTag_external_code ); 281 XML::Node dataElt = XML::FindElementByName( externalCodeElt, XMLTag_data ); 281 282 WrapperData::FileListType fileList; 282 if ( dataElt && dataElt->children) {283 for ( xmlNodePtr current = dataElt->children; current; current = current->next) {283 if (XML::IsElement(dataElt)) { 284 for (XML::Node current = XML::GetFirstChild(dataElt); current; current = XML::GetNextNode(current)) { 284 285 if (XML::IsElement(current, XMLTag_file)) { 285 286 WrapperDataFile file; 286 287 287 xmlNodePtrnameElt = XML::FindElementByName( current, XMLTag_name );288 XML::Node nameElt = XML::FindElementByName( current, XMLTag_name ); 288 289 if (nameElt) file.name_ = XML::GetNodeValue( nameElt ); 289 290 290 xmlNodePtrpathElt = XML::FindElementByName( current, XMLTag_path );291 XML::Node pathElt = XML::FindElementByName( current, XMLTag_path ); 291 292 file.path_ = XML::GetNodeValue( pathElt ); 292 293 293 xmlNodePtrsubstElt = XML::FindElementByName( current, XMLTag_subst );294 XML::Node substElt = XML::FindElementByName( current, XMLTag_subst ); 294 295 if (substElt) file.subst_ = XML::GetNodeValue( substElt ); 295 296 … … 303 304 throw WrapperFileParsingException(HERE) << "Unknown type (" << type_ 304 305 << ") for file in wrapper file " << pathToFile 305 << " at line " << xmlGetLineNo(current);306 << " at line " << XML::GetNodeLineNumber( current ); 306 307 } 307 308 … … 321 322 322 323 WrapperParameter parameters; 323 xmlNodePtrwrapModeElt = XML::FindElementByName( externalCodeElt, XMLTag_wrap_mode );324 XML::Node wrapModeElt = XML::FindElementByName( externalCodeElt, XMLTag_wrap_mode ); 324 325 String wrapType_ = XML::GetAttributeByName( wrapModeElt, XMLTag_type ); 325 326 if (wrapType_ == XMLAttr_static_link) parameters.mode_ = WrapperMode::STATICLINK; … … 330 331 throw WrapperFileParsingException(HERE) << "Unknown type (" << wrapType_ 331 332 << ") for " << XMLTag_wrap_mode << " in wrapper file " << pathToFile 332 << " at line " << xmlGetLineNo(wrapModeElt);333 << " at line " << XML::GetNodeLineNumber( wrapModeElt ); 333 334 } 334 335 … … 341 342 throw WrapperFileParsingException(HERE) << "Unknown state (" << wrapState_ 342 343 << ") for " << XMLTag_wrap_mode << " in wrapper file " << pathToFile 343 << " at line " << xmlGetLineNo(wrapModeElt);344 } 345 346 347 xmlNodePtrinDataTransferElt = XML::FindElementByName( wrapModeElt, XMLTag_in_data_transfer );344 << " at line " << XML::GetNodeLineNumber( wrapModeElt ); 345 } 346 347 348 XML::Node inDataTransferElt = XML::FindElementByName( wrapModeElt, XMLTag_in_data_transfer ); 348 349 String inMode_ = XML::GetAttributeByName( inDataTransferElt, XMLTag_mode ); 349 350 if (inMode_ == XMLAttr_files) parameters.in_ = WrapperDataTransfer::FILES; … … 356 357 throw WrapperFileParsingException(HERE) << "Unknown mode (" << inMode_ 357 358 << ") for " << XMLTag_in_data_transfer << " in wrapper file " << pathToFile 358 << " at line " << xmlGetLineNo(inDataTransferElt);359 } 360 361 362 xmlNodePtroutDataTransferElt = XML::FindElementByName( wrapModeElt, XMLTag_out_data_transfer );359 << " at line " << XML::GetNodeLineNumber( inDataTransferElt ); 360 } 361 362 363 XML::Node outDataTransferElt = XML::FindElementByName( wrapModeElt, XMLTag_out_data_transfer ); 363 364 String outMode_ = XML::GetAttributeByName( outDataTransferElt, XMLTag_mode ); 364 365 if (outMode_ == XMLAttr_files) parameters.out_ = WrapperDataTransfer::FILES; … … 371 372 throw WrapperFileParsingException(HERE) << "Unknown mode (" << outMode_ 372 373 << ") for " << XMLTag_out_data_transfer << " in wrapper file " << pathToFile 373 << " at line " << xmlGetLineNo(outDataTransferElt);374 } 375 376 377 xmlNodePtrcommandElt = XML::FindElementByName( externalCodeElt, XMLTag_command );374 << " at line " << XML::GetNodeLineNumber( outDataTransferElt ); 375 } 376 377 378 XML::Node commandElt = XML::FindElementByName( externalCodeElt, XMLTag_command ); 378 379 parameters.command_ = XML::GetNodeValue( commandElt ); 379 380 … … 387 388 388 389 389 Log::Debug(OSS() << "file " << pathToFile << " parsed"); 390 } 391 390 Log::Debug(OSS() << "File " << pathToFile << " parsed"); 391 } 392 393 394 /* Write the internal data to a wrapper file */ 395 void WrapperFile::writeFile(const FileName & pathToFile) 396 { 397 XMLDoc doc; 398 399 // Set the DTD of the wrapper file 400 const FileName DTDPath = Path::GetStandardWrapperDirectory() + "/" + DTDFileName; 401 XML::SetDTD( doc, XMLTag_wrapper, DTDPath ); 402 403 // Create <wrappper> node 404 XML::Node wrapper = XML::NewNode( XMLTag_wrapper ); 405 XML::SetRootNode( doc, wrapper ); 406 407 // TODO: Add DTD node 408 409 // Create <library> node 410 XML::Node library = XML::NewNode( XMLTag_library ); 411 XML::AddChild( wrapper, library ); 412 413 // Create <path> node 414 XML::Node libraryPath = XML::NewNode( XMLTag_path, data_.getLibraryPath() ); 415 XML::AddChild( library, libraryPath ); 416 417 // Create <description> node 418 XML::Node description = XML::NewNode( XMLTag_description ); 419 XML::AddChild( library, description ); 420 421 // Create <variable-list> node 422 XML::Node variableList = XML::NewNode( XMLTag_variable_list ); 423 XML::AddChild( description, variableList ); 424 425 // Create <variable> node 426 const WrapperData::VariableListType vList = data_.getVariableList(); 427 for (WrapperData::VariableListType::const_iterator it = vList.begin(); it != vList.end(); ++it) { 428 const WrapperDataVariable & theVar = (*it); 429 XML::Node variable = XML::NewNode( XMLTag_variable ); 430 XML::SetAttribute( variable, XMLTag_id, theVar.id_ ); 431 XML::SetAttribute( variable, XMLTag_type, (theVar.type_ != WrapperDataVariableType::OUT) ? XMLAttr_in : XMLAttr_out ); 432 if (theVar.gradient_ == WrapperComputedGradient::YES) XML::SetAttribute( variable, XMLTag_computed_gradient, XMLAttr_yes ); 433 XML::AddChild( variableList, variable ); 434 435 // Create <comment> node 436 if (! theVar.comment_.empty()) { 437 XML::Node comment = XML::NewNode( XMLTag_comment, theVar.comment_ ); 438 XML::AddChild( variable, comment ); 439 } 440 441 // Create <unit> node 442 if (! theVar.unit_.empty()) { 443 XML::Node unit = XML::NewNode( XMLTag_unit, theVar.unit_ ); 444 XML::AddChild( variable, unit ); 445 } 446
