Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

Learn more about...

AspDotNetStorefront
DotFeed

xmlpackage xsl template output not as expected

Working with 9.4.0.0 xmlpackage and have a query the calls the Ratings table for a specific productID.   The below will output but not as expected.

The below code shows it as:

<div id="ProductRatings">
  <h3>Past Reviews/Comments</h3>
  <ul>
  </ul>
</div>

    <li>item</li>
    <li>item 2</li>
    <li>item 3</li>

I want it to be:

<div id="ProductRatings">
  <h3>Past Reviews/Comments</h3>
  <ul>
    <li>item</li>
    <li>item 2</li>
    <li>item 3</li>
  </ul>
</div>

Any ideas how I can change to insert where I have the call-template?

<xsl:template name="showPastProductRatings">
                <div id="ProductRatings">
                    <h3>Past Reviews/Comments:</h3>
                    <ul>
                        <xsl:call-template name="commentsLoop" />                       
                    </ul>
                </div>
            </xsl:template>
            
            <xsl:template name="commentsLoop" match="RatingRow">
                <xsl:param name="pCurRating" select="Rating"></xsl:param>
                    <xsl:if test="./Rating != ''">
                        <li>
                        <xsl:call-template name="showAvgRatingOnly">
                            <xsl:with-param name="pRating2" select="Rating"/>
                            <xsl:with-param name="pStart2" select="1"/>
                            <xsl:with-param name="pEnd2" select="5"/>
                        </xsl:call-template>
                        - <xsl:value-of select="Comments" disable-output-escaping="yes"/>
                        </li>
                    </xsl:if>
            </xsl:template>

 

asked Apr 11, 2014 in MultiStore by lleemon (150 points)

1 Answer

0 votes

Hi Lee,

The match attribute in your template tag is causing the template to fire off automatically, based on the query results. 

Change 

<xsl:template name="commentsLoop" match="RatingRow">

To

<xsl:template name="commentsLoop">

Let me know if that works out for you!

Sincerely,
Robert

answered Apr 11, 2014 by Robert (3,440 points)

After I do this it spits out all the values of the rating table.  Before it worked as expected but didn't put inside the calling template.

Before screenshot:

Before image

After change screenshot

After change image

Runtime xml

Runtime xml

Please share entire Xml Package, including query.

It was larger then 8000 characters so had to save as file:

Here

Lee,

Comment out or remove the following:


<xsl:apply-templates select="/root/Ratings/RatingRow" />

Update your commentsLoop template, as follows:

<xsl:template name="commentsLoop">
                <xsl:param name="pCurRating" select="Rating"></xsl:param>
                <xsl:for-each select="/root/AvgRatingForProduct/AvgPrdRating">
                      <xsl:if test="Rating != ''">
                          <li>
                          <xsl:call-template name="showAvgRatingOnly">
                              <xsl:with-param name="pRating2" select="Rating"/>
                              <xsl:with-param name="pStart2" select="1"/>
                              <xsl:with-param name="pEnd2" select="5"/>
                          </xsl:call-template>
                          - <xsl:value-of select="Comments" disable-output-escaping="yes"/>
                          </li>
                      </xsl:if>
                </xsl:for-each>
            </xsl:template>

 

 

...