Thank you for your help, but I never did resolve this, and ended up changing form. I now am faced with the same issue and this is maddening. I tried your template again and I know it is something I am doing...
If I just put the expression into - Text Box Properties/Default Value/Value field (count(preceding-sibling::my:ASSEMBLYINSPECTION) + 1) I can click ok without error. (although it still doesn't work)
But if I go to the same location and choose fx and try to add my xpath field in the formula field, I get the error of "Node-test expected. count(preceding-sibling::-->..<--/..) + 1",
If I just manually type in my node in the formula bar I get the error ""preceding-sibling::ASSEMBLYINSPECTION" does not point to a valid location path of a field or group."
Can anyone help me with this?