Monday, March 07, 2005

(Office) Word quits on Print Preview

After much troubleshooting, reinstalling office, creating a new user profile, this error was still happening. Realized the problem was simply related to a corrupt printer driver. Changed the default printer to another printer and the problem was partially solved.

After deleting and reinstalling this HP1300N required printer, the driver still seemed to be the corrupt one. So tried this KB from Microsoft.

Steps to Manually Remove and Reinstall a Printer Driver

Basically need to delete registry keys at

HKEY_LOCAL_MACHINE\System\CurrentControlSet
\ControlPrintEnvironments\Windows NT x86\Drivers\Version-x\<printer>

and files at

%SystemRoot%\System32\Spool\Drivers
Did that. Reinstalled the printer driver. Solved the problem.

Tuesday, March 01, 2005

(XSLT) Encoding URL parameters

During XSL Transformation, I had a problem where dynamically generated URL parameters contained data that needs to be URL Encoded.

example from an xsl stylesheet

<a href="http://mywebsite/servlet?param1={xmldata}">link</a>

The xml data may contain values that may not be transported correctly (e.g., &).

A solution that seems to work is

<a onclick="this.href+=encodeURIComponent('{xmldata}');" href="http://mywebsite/servlet?param1=">link</a>

Note: Javascript has different functions for encoding URLs. Refer this.

Main points to remember about the various functions are
  • escape() will not encode: @*/+
  • encodeURI() will not encode: !@#$&*()=:/;?+'
  • encodeURIComponent() will not encode: !*()'