Integral of a dot product If I integrate a dot product (e.g. $\vec E \cdot \mathrm d \vec s$), then the dot product itself becomes $|\vec E| |\mathrm d \vec s| \cos\theta $. But when I try to integrate the dot product itself, I can see now there is $|\mathrm d\vec s|$, not $ds$ (not a vector). Many books anyway treat $|\mathrm d\vec s|$ and $\mathrm ds$ (not a vector) as the same thing, so they solve the integral. These kinds of books replace $|\mathrm d\vec s|$ with $ds$ which is a differential in mathematical terms.
Why do this happen?
 A: $|\mathrm ds|$ and $\mathrm d \vec s$ are not the same thing, though they might be written as such depending on the conventions of the book you're using, or how much slack is allowed in terms of notation.
As an example, take a path $C$ where $(x(t),y(t)) = (t,t)$ for $t \in [0,1]$ and a constant vector field $\vec F = (1,0)^T$. Then we have straightforwardly,
$$\int_C \vec F \cdot \mathrm d \vec s = \int_0^1 (1,0)^T \cdot (\mathrm dt, \mathrm dt)^T = \int_0^1 \mathrm dt = 1.$$
Now let us use the formula for the dot product:
$$\int_C |\vec F| |\mathrm d \vec s| \cos \theta = \cos \frac{\pi}{4}\int_0^1 \sqrt{2\mathrm dt^2} = \sqrt{2} \cos \frac{\pi}{4}=1.$$
This case is easier as the angle between the path and the vector field, $\theta$, remains constant. In the general case, $\theta = \theta(t)$, i.e. it will depend where along the path you are.
Generally you will find the first method easier for computations in a general situation, but for many physics problems, $|\vec A||\vec B| \cos\theta$ may simplify.
A: Nice question. To put it simply: when you are integrating a vector along a path (of which the $d\vec{s}$ is the infinitesimal increment) to perform the integral in practice you will need some sort of parameterization of the curve.
In fact the extremes of integration in cases like the one you mentioned are not vectors, but scalars. So you indeed get a differential of a scalar, but as a result of an implicit change of variable, such as to use the parameterization of the curve to perform the integration.
A: Essentially, they are implicitly parameterizing the curve by arc-length. This is often used for simple curves like circles and straight lines along axes.  For instance, suppose we want to compute
$$
\int_{C}\vec{F}\cdot d\vec{l},
$$
where the curve $C$ is the line segment joining the points $\vec{r}_i = (x,y) = (0,0)$ and $\vec{r}_f = (x,y) = (a,0)$. I will typically parameterize the curve as
$$
\vec{r}(t) = (1-t)\vec{r}_i + t\vec{r}_f,
$$
where $0\leq t \leq 1$. The integral becomes
$$
\int_{C}\vec{F}\cdot d\vec{l} = \int_0^1\left(\vec{F}\cdot
\frac{d\vec{r}}{dt}\right)dt = \int_0^1\left(\vec{F}\cdot
(\vec{r}_f-\vec{r}_i))\right)dt= \int_0^1F_x~a~dt.
$$
Due to the factor of $\vec{r}_f-\vec{r}_i$, $dt \neq |d\vec{l}|$. (In fact, they don't even have the same units!)
However, one can also use the coordinate $x$ as the parameter, in which case the parameterization is
$$
\vec{r}(x) = x\hat{x},
$$
where $0\leq x\leq a$. In this case, the integral becomes
$$
\int_{C}\vec{F}\cdot d\vec{l} = \int_0^a\left(\vec{F}\cdot
\frac{d\vec{r}}{dx}\right)dx = \int_0^a\left(\vec{F}\cdot
\hat{x}\right)dx = \int_0^aF_xdx.
$$
For this special choice of parameterization, $|d\vec{l}| = dx$, because the curve is traversed with a "speed of 1".
This secon parameterization is an example of parameterization by arc-length. When you parameterize by arc-length, the parameter is the length along the curve from the initial point to the current point.  When you do this, the "speed" with which you move along the curve is 1, and so in this case we can make the (heuristic) identification of $ds = |\vec{d}l|$.
