Using XPath in a Template Part - InfoPath Dev
in

InfoPath Dev

Using XPath in a Template Part

Last post 03-07-2011 01:57 AM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-03-2011 12:54 PM

    • JohnM
    • Not Ranked
    • Joined on 01-24-2011
    • Posts 3

    Using XPath in a Template Part

    I've created a simple template part that provides a nested repeating structure with outline numbering.

     i.e. 1.       ...1.1.    ...1.1.1.  ...1.1.2.  ...1.1.3.  ...1.2.    ...1.2.1.  ...1.2.2. ...2.     
     
     This is easy to do using xpath by using for the top  level  ( “numLevel1”) :
     
    count(../preceding-sibling::my:grpLevel1) + 1

    and then for the next  levels using :

    concat(../../my:numLevel1, ".", count(../preceding-sibling::my:grpLevel2) + 1) 
    concat(../../my:numLevel2, ".", count(../preceding-sibling::my:grpLevel3) + 1) 
    concat(../../my:numLevel3, ".", count(../preceding-sibling::my:grpLevel4) + 1)
     
    Because it's a template part then it should  be reusable without having to re-implement the counting formula – what a great idea...
    When it’s previewed in the template part design – it works perfectly.

    When it’s deployed in a form template however it doesn’t work.

    Looking at the xpath reproduced in the form, the preceding-sibling bit gets collapsed:

    count(../preceding-sibling::my:grpLevel1) + 1

    becomes

    count(..) + 1

    What’s going on here ?

  • 03-07-2011 01:57 AM In reply to

    Re: Using XPath in a Template Part

    Have you tried using an absolute xpath? My guess is that InfoPath doesn't fixup the relative xpaths correctly when you add the XTP to your target form.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.