Before upgrading to Oracle APEX 3.1.2 from the Oracle APEX 2.1 that comes with Oracle Database 10g XE you should carefully read this page to know all the facts that you might loose and win. After that follow the next guide. The Oracle’s one has a minor problem.
Download APEX from here.
Unzip it to a convenient directory (/opt on a Linux machine or C:\oraclexe\apex on a Windows machine)
Start an SQL*Plus session from that directory
sqlplus / as sysdba
@apexins SYSAUX SYSAUX TEMP /i/
Reconnect to your database.
Set the images PATH for APEX (APEX_HOME is the folder where you have unzipped APEX; e.g.: /opt, C:\oraclexe)
Set the Administrator password for APEX:
Restart your XE instance.