I've been reading an economics text book ( advanced micro by Jehle) and I found this definition for the elasticity of substitution.
But I don't understand what $dlnr$ would be given that $r=x_j/x_i$. If $dln(f(x))=\dfrac{f'(x)}{f(x)}$, then what is $dln(x_j/x_i)$? $x_j/x_i$ is not even a function, with respect to what argument will this be differentiated? How would you expand this expression into derivatives?

You should focus on the internal part: $$ g(r) = \frac{d \ln MRTS_{ij}(\mathbf x(r))}{d\ln r} = \frac{d A(r)}{dB(r)} = \frac{A'(r)}{B'(r)}. $$
Only now the vertical line tells us to substitute $r$ for $x_j/x_i$.