简体   繁体   中英

Saving an XSLT template in a Commerce Server 2009 Web Part

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM