我正试图用XSLT制作一些东西,但我在网上不知道如何做到……我的目的是创建一个html和php页面,并将xsl应用于XML模式。有办法完成那项任务吗?如果是,如何?感谢
p.S.:我的XSL页面已经制作了我的html页面,但我想同时制作一个php页面,有什么方法可以做到吗?(是否有制作其他页面和制作php页面的功能?)
代码:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="xs:schema">
<html>
<head>
<meta charset = "UTF-8"/>
</head>
<body>
<center>
<form action="add.php" method="post">
<table>
<xsl:apply-templates select="xs:simpleType"/>
<xsl:apply-templates select="xs:element[matches(@name,'supervision$')]/xs:complexType"/>
<xsl:result-document>
</xsl:result-document>
</table>
</form>
</center>
</body>
</html>
</xsl:template>
是的,您可以使用以下XSLT 2.0命令<xsl:result-document
:使用XSLT创建多个文档
<xsl:result-document href="add.php" method="html">
<html>
<xsl:processing-instruction name="php">echo 'Hello World';</xsl:processing-instruction>
</html>
</xsl:result-document>
这将创建具有以下内容的add.php
:
<html><?php echo 'Hello World';></html>
您可以查看许多示例以及如何使用xslt创建多个文档:http://www.cch.kcl.ac.uk/legacy/teaching/7aavdh06/xslt/html/module_09.html