编辑:此问题应为“我如何指向上下文节点中的元素?”在这种情况下,答案很简单。从拉什的回应: "my:Line_Item_Mod_0 = 'true'"
始终使用XPath从当前节点返回元素值
另外,请原谅我,如果这是一个非常明显的问题;我不知道“上下文节点”的术语,这可能是为什么谷歌和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>
我想,以评估当前节点“国防部”值是否为1或0。我已经有做这个的表现,但由于某些原因的InfoPath条件格式没有按”不喜欢它。你可以在Line_Item_Mod_0
元素中看到这个mod表达式的结果。
我需要做的就是定位每个Line_Items
节点内的Line_Item_Mod_0
元素。我似乎无法做出一个表达式,返回其父节点的Line_Item_Mod_0
的值(或者“当前”是正确的术语)。
I.E. Line_Items
节点1将会有一个表达式,它总是返回false
的值Line_Item_Mod_0
。
我意识到这应该是简单的,但我似乎无法让我的表达式坚持在其当前节点。
表达式(count(preceding-sibling::my:*) + 1) mod 2 > 0
生成Line_Item_Mod_0
节点,但如果将其作为规则应用,则条件格式设置不会很好。我不知道为什么。
我想尝试绕过它并直接评估“真”或“假”值。
”我已经有了一个表达式,但由于某些原因,InfoPath条件格式不喜欢它,您可以在Line_Item_Mod_0元素中看到此模式表达式的结果。“我们应该在哪里看到这个?这句话使得听起来好像上面给出的XML样本的一部分是XPath表达式的* output *,但问题的其余部分表明给定的XML是*输入*到您想要找出的XPath。 – LarsH