[英]Pass parameter to C# function in XSLT
I have a XML and XSLT like this: 我有这样的XML和XSLT:
XML XML格式
<process id="1">
<task id="task1">
</task>
<task id="task2">
</task>
...
</process>
XSLT XSLT
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
public string GetStartTask(int ProcessID)
{
return StartTask(ProcessID);
}
]]>
</msxsl:script>
...
<xsl:if test="@id = user:GetStartTask(<xsl:value-of select="/../@id"/>)">
...
</xsl:if>
...
( StartTask
is method that return string.) (
StartTask
是返回字符串的方法。)
In code above I try to pass process id
to GetStartTask
function by this: 在上面的代码中,我尝试通过以下方式将
process id
传递给GetStartTask
函数:
<xsl:value-of select="/../@id"/>
But this code is incorrect. 但是此代码不正确。 I read many post but I don't find syntax for this issue.
我读了很多文章,但找不到此问题的语法。
It would be very helpful if someone could explain solution for this issue. 如果有人可以解释此问题的解决方案,这将非常有帮助。
I think you meant to write: 我想你打算写:
<xsl:if test="@id = user:GetStartTask(../@id)">
This is assuming you're in the context of task
and you want to compare the value of the current task's id
with the value returned by the GetStartTask()
function with the parent process id
as the argument. 这是假设您处于
task
上下文中,并且您想将当前任务的id
的值与GetStartTask()
函数返回的值进行比较,并以父进程的id
作为参数。
If your current context is <task>
, you should try 如果当前上下文是
<task>
,则应尝试
<xsl:value-of select="../@id" />
as an XSLT expression. 作为XSLT表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.