Aside: A similar argument leads also to $$\op X=\op1\op X\op1 =\int\!\!\int\proj{x'}\op X\proj x\,\d x\,\d x' = \int\ket xx\bra x\,\d x,$$ which is the spectral representation of the operator $\op X$.
Exercise: Show that $\op X$ is self-adjoint, $\op X=\op X^\dagger$. You need to show that $\bra f\op X\ket g=\conj{\bra g\op X\ket f}$ for arbitrary $f$ and $g$.
Exercise: Verify that $$\bra x\op D\ket f=\int\bra x\op D\ket{x'}\braket{x'}f\,\d x'$$ gives the same result, $\dslby fx$, regardless of which expression you use for $\bra x\op D\ket{x'}$. Integration by parts will be helpful here.
From this point onwards, we take $a\to-\infty$, $b\to\infty$ and assume the boundary conditions $f(x)\to0$ for $\abs x\to\infty$. The effects of choosing a different domain and boundary conditions are investigated in Example 7.66.
Thus we have two ways of expanding $\ket f$ in terms of continuous sets of basis kets: $$\ket f=\intii\ket x\braket xf\,\d x =\intii\ket x\,f(x)\,\d x \quad\text{and}\quad \ket f=\intii\kete k\braket{e_k}f\,\d k =\intii\kete k\,\tilde f(k)\,\d k.$$ We could also make an expansion using a discrete basis set, such as the set of eigenfunctions of the quantum harmonic oscillator, $\basis{u_n}$: $$\ket f = \sum_{n=0}^\infty\ket{u_n}\braket{u_n}f=\sum_{n=0}^\infty\ket{u_n}\,f_n.$$ All three representations, $\ket f\longrightarrow f(x)$, $\ket f\longrightarrow\tilde f(k)$ and $\ket f\longrightarrow f_n$ contain complete information about the vector $\ket f$.