編輯:此問題應爲「我如何指向上下文節點中的元素?」在這種情況下,答案很簡單。從拉什的迴應: "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