Sorry, I've just realised you have them in 1841. If they are in Whitchurch Canonicorum, then I continue to wonder about a second marriage. There is a large age gap between William and the baby (Frederic), and all the elder children are born out of county, so possibly all in Gloucestershire. I would guess at a marriage only a year or two before the 1841 census - there doesn't seem to be one in Gloucestershire, but there is a James Lock marriage in Bristol in Q3 1839 with two possible Anns, and another possible in Q1 1839. Bristol is part way between Cheltenham and Dorset so it seems feasible.
I think the surest way to sort this out is to get the birth certificate for Frederic or one of the younger children, then you will have the information needed to pinpoint the marriage.
scuda-j