Saving an XSLT template in a Commerce Server 2009 Web Part

319 views Asked by At

When editing a Commerce Server Product detail web part we are having a great deal of difficulty making changes to the XSLT template. These are not complex changes, just small minor changes. There is no problem with the template as I have tried it out on the w3schools XSLT editor and it works fine.

I paste the template text in the dialog and click save to overwrite the template.

I get the error "Error saving XSLT : {0}"

If instead I edit the text in the dialog without using another editor (and formatting as all the CRLFs get stripped) it works.

What am I doing wrong?

I would hope that you can edit the text outside the textbox that is provided as it has NO formatting

Here is how it comes out of the textbox:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" indent="yes" /><xsl:template match="/products/product"><H1><xsl:value-of select="properties/property[@name='DisplayName']" /></H1></xsl:template></xsl:stylesheet>

as one line. I want to edit it like this:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" indent="yes" />
  <xsl:template match="/products/product">
    <H1>
      <xsl:value-of select="properties/property[@name='DisplayName']" />
    </H1>
  </xsl:template>
</xsl:stylesheet>

Much nicer.

1

There are 1 answers

4
Dimitre Novatchev On BEST ANSWER

Do this in steps:

  1. You can write your XSLT comfortably in the IDE/editor of your choice.

  2. Work on it until it satisfies all requirements.

  3. Finally, process your XSLT stylesheet with the following transformation, and feed the result to the Commerce Server:

::

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="no"/>
    <xsl:strip-space elements="*"/>

 <xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

when this transformation is performed on your elegantly formatted code:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" indent="yes" />
  <xsl:template match="/products/product">
    <H1>
      <xsl:value-of select="properties/property[@name='DisplayName']" />
    </H1>
  </xsl:template>
</xsl:stylesheet>

the wanted result, that is acceptable by Commerce Server is produced:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="html" version="1.0" indent="yes"/><xsl:template match="/products/product"><H1><xsl:value-of select="properties/property[@name='DisplayName']"/></H1></xsl:template></xsl:stylesheet>