The paper deals with the creation in electronic form of editions of texts provided with an apparatus indicating variants. The method is to encode the entire text as an XML document with a very simple structure, dividing the text into a linear, non-hierarchical series of segments, each segment consisting of a section of text plus the variants to that section with an indication of the witness(es) in which they are found. XSLT is used to number the portions of text and the corresponding variants and then to extrapolate the variants into an apparatus. The result is an XML document with a relatively simple structure. Additional mark-up may be added at this stage if required, for example further automatic transformation into a TEI-conformant document.