php function defined in xsl [duplicate]
I have this XSL file:
< ?xml version="1.0" encoding="utf-8"?>
< xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl script" xmlns:script="script">
<开发者_开发知识库 msxsl:script implements-prefix="script" language="C#">
< ![CDATA[
public string formatDate(string sDate)
{
string sRetval = "";
try
{
System.IFormatProvider format = new System.Globalization.CultureInfo(sSourceCulture);
System.IFormatProvider format2 = new System.Globalization.CultureInfo(sTargetCulture);
DateTime dDate = DateTime.Parse(sDate, format);
sRetval = dDate.ToString(sFormat, format2);
}
catch {}
return sRetval;
}
]] >
< / msxsl:script>
< xsl:template match="/">
< ?xsl:if test="count(//item) > 0">
<br />
<div id="ForumsBox" class="NoTabBox300">
<h2>forum</h2>
<div class="NoTabBoxContent">
<ul class="Article">
<xsl:apply-templates select="//item" />
</ul>
</div>
</div>
</xsl:if>
< /xsl:template>
< xsl:template match="item">
< xsl:if test="position() <= 5">
<li>
< xsl:value-of select="script:formatDate(pubDate)" />
< xsl:text disable-output-escaping="yes"> </xsl:text>
...
< /xsl:template>
</ xsl:stylesheet>
There is a C# function define in CDATA section. Does php support something similar?
It appears that you cannot do exactly what you want, hoever, this may be of some help Calling PHP Functions from XSL. I am not sure if this is what you were looking for, but does contain some good information. As far as the actual defining of a function, well given that it uses Microsoft's schema, I am sure this functionality was written up by Microsoft which is why you can do it with C#.
精彩评论