views:

15

answers:

1

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"&gt;&lt;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"&gt;
  <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  A: 

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"&gt;
    <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"&gt;
  <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>
Dimitre Novatchev
I will give that a try, but it is crazy insane that whitespace makes it choke.
Jeff Cuscutis
@Jeff-Cuscutis: You have two options: 1. To complain to the team and wait for the next version coming 2-3 years from now. 2. Use my solution. :)
Dimitre Novatchev
Your solution works. Thanks! It is still insane that whitespace and newlines make it choke. There was also nothing online from anyone about this. Are SharePoint users so beaten down by the soul crush of having to work in SharePoint that this doesn't even faze them?
Jeff Cuscutis
it's been my experience that whitespace alone is not enough to make it choke.
David Alpert