Solved: “XSLT compile error. ‘wsp’ is an undeclared prefix.”

If you upgrade an XSLT file to a newer version manually (by changing meta tags), you may run into these error messages when you try to open corresponding XML file:

XSLT compile error
‘wsp’ is an undeclared prefix. Line 27, position 12
‘wx’ is an undeclared prefix. Line 558, position 44

Root Cause

Microsoft announced a new XML format called Office Open XML (OOXML or OpenXML) in Microsoft Office 2007 products. Some XML keywords such as wsp and wx were depreciated with this new format. Therefore, when you upgrade your XSLT file, you’ll probably run into some syntax issues.

Solution

You need to replace those depreciated keywords with their descendants. It takes some time to find newer keywords. I had to deal with wsp and wx in my file. I replaced them with w. For example:

  • w:rsidTr instead of wsp:rsidTr
  • w:rsidP instead of wsp:rsidP
  • w:sz instead of wx:bdrwidth

Recommendation

The solution above might be exteremly tedious if you’re dealing with a big XSLT file. You may want to find an easier way to upgrade your XSLT files. I’d recommend this approach:

  1. Copy your content into a Microsoft Office version newer than 2003
  2. Save it as XML
  3. Open this XML file in XML Notepad
  4. Save it as XSLT

You will have an upgraded XSLT after these steps. You don’t need to upgrade your files manually any more.

References

One thought on “Solved: “XSLT compile error. ‘wsp’ is an undeclared prefix.”

Leave a Reply