내가 할 수있는 경우 궁금 어떻게 내가 내 XSLT 템플릿 내부 코드를 포함 할 수 있습니다 ... 내가 함수, 변수 등을 추가 할, 내가 <xsl:choose>
를 사용할 수 있지만 그건 내 요구를 충족하지 않습니다 알고 ...XSLT 템플릿 안에 일반 PHP 코드가 있습니까?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:php="http://php.net/xsl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match="BackgroundReportPackage">
<!--- here i would like to add code like ---->
if ($dateofcharge < 7) {
return '
<xsl:for-each select="Charge">
<table class="special2" cellpadding="0">
<tr class="tr-border-bottom">
<td class="front-td-text" valign="top">Charge ID: </td>
<td class="minimalec">
<xsl:value-of select="ChargeId"/>
</td>
</tr>
<tr class="tr-border-bottom">
<td class="front-td-text" valign="top">Charge Type Classification: </td>
<td class="minimalec">
<xsl:value-of select="ChargeTypeClassification"/>
</td>
</tr>
</table>
';
} else {
do nothing
}
<!--- keep in mind that this code i've added is just for presentational purposes TO show you, how i want to use php code --->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
희망자 누구든지 도움을!
PHP 스크립트에서 xslt를 출력으로 생성 할 수 있습니다. 하지만 템플릿의 일부를 평가하기 위해 PHP에서 xslt 템플릿 호출을 할 수 있다고 생각하지 않습니다. –
http://www.php.net/manual/en/xsltprocessor.registerphpfunctions.php 및 http://php.net/manual/en/function.stream-wrapper-register.php도 참조하십시오. 'myvar : // variablename'과 같은 XML/XSLT에서도 사용할 수 있습니다. – hakre
아직 답을 수락하지 않았습니다. 답안에서 찾고있는 것을 명확하게 설명하고 주어진 답이 왜 당신을 만족시키지 못하게 할 수 있습니까? – Gordon