我在使用PHP处理指令将值设置到属性时遇到了困难:
XSLT
<li itemprop="startDate">
<xsl:attribute name="content">
<xsl:processing-instruction name="php">
echo "Monday";
?</xsl:processing-instruction>
</xsl:attribute>
Monday
</li>页面呈现良好,但属性始终为空。
输出
<li itemprop="startDate" content="">Monday</li>我期望PHP将一个值回显到属性中
发布于 2013-07-04 22:20:56
如果使用PHP通过XSLT转换XML,则可以在php中使用:
$proc->setParameter(null, 'day', 'Monday');
$proc->transformToXML($xml);然后在XSLT中使用这个变量:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
exclude-result-prefixes="php"
xsl:extension-element-prefixes="php">
<xsl:param name="day"/> <!-- Set the parameter -->
<xsl:attribute name='content'>
<xsl:value-of select="$day"/>
</xsl:attribute>万事如意!
发布于 2013-06-15 13:12:28
您没有说明如何打开XML。但是由于回显,我假设它可以/应该包含php指令。
xsl:processing-instruction在这里没有意义。试试这个:
<li itemprop="startDate">
<xsl:attribute name="content">
<?php
echo "Monday";
?>
</xsl:attribute>
Monday
</li>https://stackoverflow.com/questions/17123611
复制相似问题