Families of local rings coming from a locally ringed space Let $X$ be a topological space. For every point $x \in X$ let $R_x$ be a local ring. Under what (necessary / sufficient / necessary and sufficient) conditions is there a sheaf ${\cal O}_X$ such that $(X,\mathcal{O}_X)$ is a locally ringed space with $\mathcal{O}_{X,x} \cong R_x$ for all $x \in X$?
If $X$ is discrete, we need no conditions, and we can take the sheaf $\mathcal{O}_X(U)=\prod_{x \in U} R_x$. But in general, a necessary condition is that $x \prec y$ gives a ring homomorphism $R_x \to R_y$, and that these are compatible in the sense that $x \mapsto R_x$ extends to a functor from the specialization preorder of $X$ to the category of rings. We will also have $\mathcal{O}_X(U) \subseteq \varprojlim_{x \in U} R_x$, but probably no equality.
 A: Here is another necessary condition for the existence of such a sheaf:

For all $x \in X$ and for all $f \in R_x$, there exists a neighborhood $U$ of $x$ such that the $f$ is contained in the image of the canonical homomorphism $$\varprojlim_{y \in U} R_y \to R_x.$$

For suppose that such a sheaf $\mathcal{O}$ exists and let let $f \in R_x$. By definition of the stalk $\mathcal{O}_x$, there exists a neighborhood $U$ of $x$ such that $f$ is in the image of $\mathcal{O}(U) \to \mathcal{O}_x \cong R_x$. But as you indicate above, this factors through the natural map $\varprojlim_{y \in U} R_y \to R_x$, whence $f$ is in the image of the latter homomorphism.
I can't see at the moment whether this is a sufficient condition.  My temptation would be to assume that this condition holds and construct a (pre?)sheaf $\mathcal{O}$ by $\mathcal{O}(U) = \varprojlim_{x \in U} R_x$.  (Even if this isn't a sheaf, which I'm too lazy/busy to check right now, its sheafification will have the same stalks.)  Is this condition enough to ensure that $\mathcal{O}_x \cong R_x$?  If not, is there some simple condition that may be added to guarantee this isomorphism?
Edit: As pointed out by Martin in the comments, assuming the condition above, the sheaf defined by $\mathcal{O}(U) = \varprojlim_{x \in U} R_x$ is constructed in such a way that there are natural surjections $\mathcal{O}_x \twoheadrightarrow R_x$.  To make the necessary condition sufficient, we only need to ensure that these surjections are also injective.  This can be prhased by demanding, for all $x$, that $$\varinjlim_{\mbox{open }U \ni x} \left( \varprojlim_{y \in U} R_y \right) \to R_x$$ is an isomorphism.  
Alternatively, injectivity of the maps may be obtained via the following condition (which is also necessary):

For all $x \in X$ and every open neighborhood $U$ of $x$, if $g \in \varprojlim_{y \in U} R_y$ is in the kernel of $\varprojlim_{y \in U} R_y \to R_x$, then there exists a neighborhood $V \subseteq U$ of $x$ such that $g$ is in the kernel of the natural map $\varprojlim_{y \in U} R_y \to \varprojlim_{y \in V} R_y$.

