To prove this we will use Schemes, Lemma \ref{schemes-lemma-glue-functors}. First we define a contravariant functor $F$ from the category of schemes to the category of sets. Namely, for a scheme $T$ we set $$ F(T) = \left\{ \begin{matrix} (g, \{h_U\}_{U \in \mathcal{B}}), \ g : T \to S, \ h_U : g^{-1}(U) \to X_U, \\ f_U \circ h_U = g|_{g^{-1}(U)}, \ h_U|_{g^{-1}(V)} = \rho^U_V \circ h_V \ \forall\ V, U \in \mathcal{B}, V \subset U \end{matrix} \right\}. $$ The restriction mapping $F(T) \to F(T')$ given a morphism $T' \to T$ is just gotten by composition. For any $W \in \mathcal{B}$ we consider the subfunctor $F_W \subset F$ consisting of those systems $(g, \{h_U\})$ such that $g(T) \subset W$. \medskip\noindent First we show $F$ satisfies the sheaf property for the Zariski topology. Suppose that $T$ is a scheme, $T = \bigcup V_i$ is an open covering, and $\xi_i \in F(V_i)$ is an element such that $\xi_i|_{V_i \cap V_j} = \xi_j|_{V_i \cap V_j}$. Say $\xi_i = (g_i, \{h_{i, U}\})$. Then we immediately see that the morphisms $g_i$ glue to a unique global morphism $g : T \to S$. Moreover, it is clear that $g^{-1}(U) = \bigcup g_i^{-1}(U)$. Hence the morphisms $h_{i, U} : g_i^{-1}(U) \to X_U$ glue to a unique morphism $h_U : U \to X_U$. It is easy to verify that the system $(g, \{f_U\})$ is an element of $F(T)$. Hence $F$ satisfies the sheaf property for the Zariski topology. \medskip\noindent Next we verify that each $F_W$, $W \in \mathcal{B}$ is representable. Namely, we claim that the transformation of functors $$ F_W \longrightarrow \Mor(-, X_W), \ (g, \{h_U\}) \longmapsto h_W $$ is an isomorphism. To see this suppose that $T$ is a scheme and $\alpha : T \to X_W$ is a morphism. Set $g = f_W \circ \alpha$. For any $U \in \mathcal{B}$ such that $U \subset W$ we can define $h_U : g^{-1}(U) \to X_U$ be the composition $(\rho^W_U)^{-1} \circ \alpha|_{g^{-1}(U)}$. This works because the image $\alpha(g^{-1}(U))$ is contained in $f_W^{-1}(U)$ and condition (a) of the lemma. It is clear that $f_U \circ h_U = g|_{g^{-1}(U)}$ for such a $U$. Moreover, if also $V \in \mathcal{B}$ and $V \subset U \subset W$, then $\rho^U_V \circ h_V = h_U|_{g^{-1}(V)}$ by property (b) of the lemma. We still have to define $h_U$ for an arbitrary element $U \in \mathcal{B}$. Since $\mathcal{B}$ is a basis for the topology on $S$ we can find an open covering $U \cap W = \bigcup U_i$ with $U_i \in \mathcal{B}$. Since $g$ maps into $W$ we have $g^{-1}(U) = g^{-1}(U \cap W) = \bigcup g^{-1}(U_i)$. Consider the morphisms $h_i = \rho^U_{U_i} \circ h_{U_i} : g^{-1}(U_i) \to X_U$. It is a simple matter to use condition (b) of the lemma to prove that $h_i|_{g^{-1}(U_i) \cap g^{-1}(U_j)} = h_j|_{g^{-1}(U_i) \cap g^{-1}(U_j)}$. Hence these morphisms glue to give the desired morphism $h_U : g^{-1}(U) \to X_U$. We omit the (easy) verification that the system $(g, \{h_U\})$ is an element of $F_W(T)$ which maps to $\alpha$ under the displayed arrow above. \medskip\noindent Next, we verify each $F_W \subset F$ is representable by open immersions. This is clear from the definitions. \medskip\noindent Finally we have to verify the collection $(F_W)_{W \in \mathcal{B}}$ covers $F$. This is clear by construction and the fact that $\mathcal{B}$ is a basis for the topology of $S$. \medskip\noindent Let $X$ be a scheme representing the functor $F$. Let $(f, \{i_U\}) \in F(X)$ be a ``universal family''. Since each $F_W$ is representable by $X_W$ (via the morphism of functors displayed above) we see that $i_W : f^{-1}(W) \to X_W$ is an isomorphism as desired. The lemma is proved.