XSLT processing — xsl:strip-whitespace issues

Generally, it’s not a good idea to globally strip whitespace from data being transformed into MARC.  The spacing is sometimes important.  However, I understand there are times when this is desireable.

In MarcEdit, if you use the <xsl:strip-whitespace> command, you will get an error.  It will look something like this:


This is due to how MarcEdit handles XML Transformations.  The tool compiles the transformations, reading the data via an xml text stream.  Because of this, processing conditions like this are problematic.  If you need to remove whitespace, it’s best to do it by element being transformed using the normalize-space element, or if needed globally, but using this template.

<xsl:template match=”text()”>
<xsl:value-of select=”normalize-space(.)”/>