English 中文(简体)
如何将变数的数值定在需要一条道路的征象中
原标题:How to set the value of a variable in a udf requiring a path-call

我试图在异常低价竞标中使用一个用户界定的职能,这一再称作某种扼杀的价值。 这一举动是基于XPath的表述结果,该表述在单一功能呼吁的期限内没有变化。 我认为,把它分配给一个变数,而不是重新审视,是一个好的想法。

Unfortunately, at least in Saxon s implementation, you cannot use an XPath expression requiring a node inside a function, even one based on an absolute path, without first using a throw-away line to let the function know you are discussing the root document rather than some other one.

因此,例如,以下法典有一处错误:

<xsl:function name="udf:LeafMatch">
<xsl:param name="sID"></xsl:param>
<xsl:variable name="myLeaf" select="/potato/stem[@sessionID=$sID][scc]/scc/@leafnumber"/>

通常,解决办法只是首先指任何全球变量,以提供环境。 例如,在ud子里的以下工程(烟 the是一种带有根 no的变量):

<xsl:for-each select="$root">
<xsl:value-of select="/potato/stem[@sessionID=$sID][scc]/scc/@leafnumber"/>
</xsl:for-each>

但是,在试图利用Xpath确定变数的价值时,这样做是徒劳的,因为我不允许将这一表述放在一边。

我也试图利用这一手段。

<xsl:choose><xsl:when select"$root"><xsl:value-of select="/potato/stem[@sessionID=$sID][scc]/scc/@leafnumber"/></xsl:when></xsl:choose>

to give it context, going on what I saw here:http://www.stylusstudio.com/xsllist/200504/post00240.html

要么没有工作。

FWIW将变数移入功能是有问题的,因为用来界定“米切叶”的Xpath表述取决于环境节点,我不知道如何使Xpath在目前情况下的节点上以价值观为基础的一条道路。

例如,在称为这一职能的法典中,我有以下一些内容:

<xsl:for-each select="/potato/stem[eye]">
<leaf = "{udf:LeafMatch(@sessionID)}"/>
</xsl:for-each>

Im在//tem(眼) no子下工作,利用ud寻找具有相同价值的@/tem/tem子。 我不知道如何在XML树的完全不同部分寻找其他节点之前,从目前情况下的节点中提一下@sessionID的价值,因此,我使用了一种ud。 在我决定尝试为扼杀而使用一个变量之前,它一直工作得尽美,而不是让处理者每次看管。

我试图避免一个层次的深度(我的职能本身称为一个有名的模板,或把一个有名的模板放在我的原封顶上,而这一模板称为功能)。

因此,我的问题是:

A. 导 言 对于用户界定的职能,我如何设定一个取决于XPath表达的变量?

B. 出席情况 是否在Xpath使用从你试图测试的Xpath表述的目前内容节点中得出的数值?

最佳回答

因此,我的问题是:

A. For a user-defined function, how do I set a variable that depends on an XPath expression?

B. Is there a snazzy way in Xpath to use values drawn from the current content node in the predicates of the Xpath expression you are trying to test?

这两个问题都很不明确。

A:我假定你实际上指的是:

"Inside an xsl:function how do I define a variable that depend on the context node?"

www.un.org/Depts/DGACM/index_spanish.htm 答案:你可以。 根据定义,在<条码>xsl:功能内没有环境节点。 <

"Within the body of a stylesheet function, the focus is initially undefined; this means that any attempt to reference the context item, context position, or context size is a non-recoverable dynamic error. [XPDY0002]"

但是,你可以把预定的背景节点(或只是文件节点,必须作为时段使用)作为参数。 或者,或者,你可以提及一个全球确定的变量。

B. 这一问题完全无法理解:

  1. 什么是“na”?

  2. 什么是“目前的内容节点”? 请举一个例子,说明以“na”方式完成的具体任务。

问题回答

暂无回答




相关问题
passing form variables into a url with php

I have the following form which allows a user to select dates/rooms for a hotel reservation. <form action="booking-form.php" method="post"> <fieldset> <div class="select-date">...

Error: "Cannot modify the return value" c#

I m using auto-implemented properties. I guess the fastest way to fix following is to declare my own backing variable? public Point Origin { get; set; } Origin.X = 10; // fails with CS1612 Error ...

C-style Variable initialization in PHP

Is there such a thing as local, private, static and public variables in PHP? If so, can you give samples of each and how their scope is demonstrated inside and outside the class and inside functions?

C#/.NET app doesn t recognize Environment Var Change (PATH)

In my C# app, I am programmatically installing an Oracle client if one is not present, which requires adding a dir to the PATH system environment variable. This all works fine, but it doesn t take ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

How to dynamically generate variables in Action Script 2.0

I have a for loop in action script which I m trying to use to dynamically create variable. Example for( i = 0 ; i &lt 3 ; i++) { var MyVar+i = i; } after this for loop runs, i would like to ...

热门标签