编辑:这个问题应该是“我如何指向上下文节点中的一个元素?” 在这种情况下,答案很简单。从拉什的回应:
"my:Line_Item_Mod_0 = 'true'"
另外,如果这是一个非常明显的问题,请原谅我;我不知道“上下文节点”的术语,这可能就是为什么 google 和 StackOverflow 搜索没有太大帮助的原因。
阅读问题的其余部分以了解上下文。
我需要一个 XPath 表达式,它返回每个节点中的当前Line_Item_Mod_0
值,以便有条件地格式化 MS InfoPath 表单。我对 XPath 很陌生,我不知道这种行为(由表达式显示)的适当术语是什么。这是我的 XML:
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.504" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\c37482678ae440c9\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><?mso-infoPath-file-attachment-present?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-05-05T19:56:08" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:MasterSection>
<my:Project_Information>
<my:Line_Items>
<my:Counter>1</my:Counter>
<my:Authorized_Number>4</my:Authorized_Number>
<my:XPathLINCounter>Line Item 1</my:XPathLINCounter>
<my:Line_Item_Mod_0>false</my:Line_Item_Mod_0>
</my:Line_Items>
<my:Line_Items>
<my:Counter>2</my:Counter>
<my:Authorized_Number>7</my:Authorized_Number>
<my:XPathLINCounter>Line Item 2</my:XPathLINCounter>
<my:Line_Item_Mod_0>true</my:Line_Item_Mod_0>
</my:Line_Items>
<my:Line_Items>
<my:Counter>3</my:Counter>
<my:Authorized_Number>2</my:Authorized_Number>
<my:XPathLINCounter>Line Item 3</my:XPathLINCounter>
<my:Line_Item_Mod_0>false</my:Line_Item_Mod_0>
</my:Line_Items>
</my:Project_Information>
</my:MasterSection>
</my:myFields>
我正在尝试评估当前节点的“mod”值是 1 还是 0。我已经有一个执行此操作的表达式,但由于某种原因 InfoPath 条件格式不喜欢它。Line_Item_Mod_0
您可以在元素中看到此 mod 表达式的结果。
我需要做的就是定位每个节点中的Line_Item_Mod_0
元素。Line_Items
我似乎无法创建一个表达式来返回Line_Item_Mod_0
其父节点的值(或者“当前”可能是正确的术语)。
IE节点 1 中将有一个表达式,Line_Items
该表达式总是返回false
.Line_Item_Mod_0
我意识到这应该很简单,但我似乎无法让我的表情停留在其当前节点内。
该表达式(count(preceding-sibling::my:*) + 1) mod 2 > 0
生成Line_Item_Mod_0
节点,但如果我将其作为规则应用,则它不能很好地处理条件格式。我说不出为什么。
我想尝试绕过它并直接评估“真”或“假”值。