First, finely chop the onions.  This makes them smaller, faster-cooking, and less of a textural presence in the dish.  Do it by cutting straight through the poles of the onion, resulting in two halves.  Then chop off the knobs and peel off the outer layer.  Run the knife 8 or 9 times along the vertical (from pole to pole), but *don't* sever one end completely.  Cut finely across these verticals to make a fine dice.  Run the knife over the pile a few times if your cut isn't small enough.

Second, cook the onions. The purpose of sweating is to draw moisture out, concentrating the flavor and enhancing conversion from starch to sugar. Heating the onions releases their aroma and reduces the chemical bitterness they exhibit when raw.  Heat up some oil in a pan to medium-low/medium heat.  Add the onions.  Add salt.  Leave them.  I wouldn't cover the pan, since the lid will prevent steam from escaping.  Stir once in a while to prevent sticking or burning.  The onions will get soft, then translucent, and eventually limp and browned if you want that (this is typically considered caramelized and considered a different thing, though it's just further along the same spectrum).

That's how I'd do it and why.  I don't know if it's a textbook answer.