First define a new class which will use the global variable $modx and the magic functions __call(), __set() and __get() :
class MyDocumentParser{
//put here your new variables
//put here your new functions
//put here your new definitions of old functions
public function __call($name, $arguments){
global $modx;
if(count(arguments==1)) return $modx->$name($arguments[0]);
else return $modx->$name($arguments);
}
public function __set($var, $value){
global $modx;
$modx->$var=$value;
}
public function __get($var){
global $modx;
return $modx->$var;
}
}
Then you create an object :
$modx2=new MyDocumentParser();
You can use all the API of $modx with $modx2, and you can define new functions for $modx2 without changing the code of MODx.