Thanks for your solution ..
I was looking at techniques for embedding php code in xhtml files using a technique like this .. for svg ..
this would require a new mime type
to be created in Apache mime.types file .. let's call it
.pxhtml .. similar to .psvg example
In fact you could embed svg in an xform
# added new type pxhtml .. embedding php in xhtml files
application/xhtml+xml xhtml xht pxhtml
But it seems that your code might offer a neater solution ..
also see here .. accepting XForms in PHP