开发者

How to use a php variable with xsl?

开发者 https://www.devze.com 2023-03-21 03:53 出处:网络
How would I use an auto incremented php variable in XSL? XSL? function xslt_string($key){ $key++; return isset($saved[$key]) ? $saved[$key] : \'\'开发者_如何学JAVA;

How would I use an auto incremented php variable in XSL?

XSL?

function xslt_string($key){
$key++;
return isset($saved[$key]) ? $saved[$key] : ''开发者_如何学JAVA;
}

In XML?

<xsl:variable name="phpstring" 
select="php:function('xslt_string', string('$saved[$key]'))" />
<xsl:value-of select="$post_param" />

XML NAME SPACE?

xmlns:php="/". (function on page that parses XSL)


I do it this way:

In your XSL:

<xsl:value-of select="$myVar"/>

In your PHP:

$proc = new XSLTProcessor();
//...
$proc->setParameter('', 'myVar', 'Your value here');

See XSLTProcessor::setParameter for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消