From: konrad Date: Thu, 29 Jul 2010 20:39:33 +0000 (+0000) Subject: add namespace to transactions X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=4a871b1a78b0987ad2d63efe4e1f1b23df603a2c;p=web%2Fkonrad%2Fpack.git add namespace to transactions git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@578 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/phpbase/exception.php b/phpbase/exception.php index f41c026..e4dfbc3 100644 --- a/phpbase/exception.php +++ b/phpbase/exception.php @@ -30,7 +30,7 @@ class WobTransactionError extends Exception public function printXml() { header("X-WobResponse-Status: Error"); - print("etype)."\">".xq($this->estr)."\n"); + print("etype)."\">".xq($this->estr)."\n"); } /**returns the error type*/ diff --git a/phpbase/transaction.php b/phpbase/transaction.php index c3feaef..96cb2df 100644 --- a/phpbase/transaction.php +++ b/phpbase/transaction.php @@ -30,12 +30,12 @@ class WobTransactionBase { global $_SERVER; if($_SERVER["REQUEST_METHOD"] != "POST"){ header("X-WobResponse-Status: Error"); - print("".tr("Request is not a POST Request, Aborting.")."\n"); + print("".tr("Request is not a POST Request, Aborting.")."\n"); exit(); } if(!isset($_SERVER["HTTP_X_WOBREQUEST"])){ header("X-WobResponse-Status: Error"); - print("".tr("Request is not a Wob Request, Aborting.")."\n"); + print("".tr("Request is not a Wob Request, Aborting.")."\n"); exit(); } self::$running=$_SERVER["HTTP_X_WOBREQUEST"]; @@ -104,6 +104,20 @@ class WobTransactionBase { protected function isAuthorized($transactioName){return false;} /**stub: returns the name of the user (default returns empty string)*/ protected function userName(){return "";} + + /**internal: returns an initialized XML array ("doc"=>DomDocument, "root"=>transaction rool DomElement)*/ + protected function xmlCreate($elem){ + $r=array(); + $r["doc"]=new DOMDocument; + $r["root"]=$r["doc"]->createElementNS($this->xmlNamespace(),$elem); + return $r; + } + + /**internal: converts XML array to string representation*/ + protected function xmlToString($xml){ + $xml["doc"]->appendChild($xml["root"]); + return $xml["doc"]->saveXml(); + } }; ?> \ No newline at end of file diff --git a/woc/php/phpstrans.cpp b/woc/php/phpstrans.cpp index 0043a96..721ad75 100644 --- a/woc/php/phpstrans.cpp +++ b/woc/php/phpstrans.cpp @@ -131,8 +131,8 @@ QString WocPHPServerTransaction::trnOutput(const WocTransaction&trn) { QStringList sl=trn.outputNames(); QString code="\t/*start of output encoding*/\n"; - code+="\ttry{\n\t\t$xml=new DOMDocument;\n"; - code+="\t\t$root=$xml->createElement(\"WobResponse-"+trn.name()+"\");\n"; + code+="\ttry{\n\t\t$xml=$this->xmlCreate(\"WobResponse-"+trn.name()+"\");\n"; + code+="\t\t$root=$xml['root'];\n"; for(int i=0;isvnRevision()+"\";}\n\n").toAscii()); m_transact.write(QString(" static public function svnRepositoryRoot(){return \""+woc->svnRepositoryRoot()+"\";}\n\n").toAscii()); m_transact.write(QString(" static public function svnRepositoryUrl(){return \""+woc->svnRepositoryUrl()+"\";}\n\n").toAscii()); + m_transact.write(QString(" static public function xmlNamespace(){return \""+woc->xmlNamespace()+"\";}\n\n").toAscii()); } void WocPHPTransaction::transInfo2() diff --git a/woc/proc/processor.cpp b/woc/proc/processor.cpp index 11cea42..40b0e33 100644 --- a/woc/proc/processor.cpp +++ b/woc/proc/processor.cpp @@ -129,6 +129,7 @@ bool WocProcessor::processFile(QString fn) m_wobDir=el.attribute("wobDir"); if(el.hasAttribute("name")) m_projname=el.attribute("name"); + m_xmlNS=el.attribute("xml-namespace"); }else if(tn=="Include"){ if(!processFile(m_baseDir+"/"+m_wobDir+"/"+el.attribute("file"))) diff --git a/woc/proc/processor.h b/woc/proc/processor.h index 11ff06b..3f2ddb6 100644 --- a/woc/proc/processor.h +++ b/woc/proc/processor.h @@ -100,6 +100,8 @@ class WocProcessor:public QObject QString dbSchema()const{return m_dbSchema;} /**returns the database schema version*/ QString dbVersion()const{return m_dbVer;} + /**returns the XML namespace of the project*/ + QString xmlNamespace()const{return m_xmlNS;} /**returns whether a table exists*/ bool hasTable(QString)const; @@ -134,7 +136,7 @@ class WocProcessor:public QObject private: QString m_baseDir,m_wobDir,m_verComm,m_verNeedComm,m_verHR,m_projname; QString m_svnTarget,m_svnRev,m_svnExe,m_svnRoot,m_svnUrl; - QString m_dbInst,m_dbSchema,m_dbVer; + QString m_dbInst,m_dbSchema,m_dbVer,m_xmlNS; QStringList m_docstrings; bool m_error,m_dbUpd;