a.xml
-----
<form url="foobar.php">
<field name="a" def="This is a"/>
<field name="b" def="This is b"/>
<field name="c" def="This is c"/>
</form>
a.xsl
-----
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<title>XSL demo</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="form">
<form>
<xsl:attribute name="method">POST</xsl:attribute>
<xsl:attribute name="action"><xsl:value-of select="@url"/></xsl:attribute>
<xsl:apply-templates/>
<input type="submit" value="Execute"/>
</form>
</xsl:template>
<xsl:template match="field">
<xsl:value-of select="@name"/>:
<input>
<xsl:attribute name="type">TEXT</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="@def"/></xsl:attribute>
</input>
<br/>
</xsl:template>
</xsl:stylesheet>
a.php
-----
<?php
$xml = new DOMDocument();
$xml->load("a.xml");
$xsl = new DOMDocument();
$xsl->load("a.xsl");
$t = new XSLTProcessor();
$t->importStylesheet($xsl);
echo $t->transformToXML($xml);
?>
output
------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>XSL demo</title>
</head>
<body><form method="POST" action="foobar.php">
a:
<input type="TEXT" name="a" value="This is a"><br>
b:
<input type="TEXT" name="b" value="This is b"><br>
c:
<input type="TEXT" name="c" value="This is c"><br>
<input type="submit" value="Execute">
</form></body>
</html>