Safety Capacitor Selection
The X2 rating is mainly its ability to withstand high voltage surges.  It is somewhat lower than the X1 cap and quite a bit lower than the Y1 and Y2 caps.  Otherwise, you select voltage rating and value in much the same way as any other place.  X1, X2 caps are for across-the-line applications and Y1, Y2 are for line to earth connecting.  Although these caps are intended for AC applications as RF (EMI) filters, you will find them unsuitable for applications such as snubbers, etc.  They do not have the greatest dissipation factors.