Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 7th, 2016, 03:31 AM
Registered User
 
Join Date: Mar 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Need to select unique values in for-each loop

Hi,
I am trying to fetch only the unique values from a given XML using the XSL.
Below mentioned is the input xml snippet:
<FEATURE>
<FTEMPLATE>
<FT_ID>1425380474637</FT_ID>
<FT_NAME>Size</FT_NAME>
<FT_SHORTNAME>Size</FT_SHORTNAME>
<FT_DESCR>-</FT_DESCR>
</FTEMPLATE>
<FVALUE>L</FVALUE>
</FEATURE>
I am executing a for-each loop on <xsl:for-each select="./PRODUCT_FEATURES/FEATURE"> and checking if the value of node contains Size as it value. If yes, then select <FVALUE>.
The problem here is that whenever the for-each loop executes, it will select the <FVALUE>, without considering if the <FVALUE> is unique or not.

I am expecting an output like:
<variation-attribute attribute-id="Size" variation-attribute-id="Size">
<display-name xml:lang="x-default">Size</display-name>
<variation-attribute-values>
<variation-attribute-value value="L"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="M"/>
<variation-attribute-value value="XL"/>
</variation-attribute-values>
</variation-attribute>

Right now i get the output as:
<variation-attribute attribute-id="Size" variation-attribute-id="Size">
<display-name xml:lang="x-default">Size</display-name>
<variation-attribute-values>
<variation-attribute-value value="L"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="M"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="L"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="M"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="L"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="M"/>
</variation-attribute-values>
</variation-attribute>

Please help me out in solving this issue.

Thanks in advance.
 
Old March 7th, 2016, 04:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, it's very difficult to help you since you don't show your code. That means we have no idea how close you are to a correct solution, and we don't know which concepts you have understood and which you haven't.

Your problem sounds like a classic grouping problem. Use XSLT 2.0 if you can, which has an xsl:for-each-group instruction. If you are stuck with XSLT 1.0, look up "Muenchian Grouping" in the index of your favourite Wrox XML programming book.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old March 7th, 2016, 05:27 AM
Registered User
 
Join Date: Mar 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,
Please find the code below. May be it can give you a better idea of the problem i am facing. I cannot use the grouping method as the for loop and the value to be selected are at different nodes.
I have highlighted the node where i am facing the issue. The output is coming as below fr the size . I am expecting to remove the duplicate values from the <variation-attribute-value> node. Hope I am able to clearly explain my issue.

<variation-attribute attribute-id="Size" variation-attribute-id="Size">
<display-name xml:lang="x-default">Size</display-name>
<variation-attribute-values>
<variation-attribute-value value="L"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="M"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="L"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="M"/>
<variation-attribute-value value="S"/>
<variation-attribute-value value="L"/>
<variation-attribute-value value="XL"/>
<variation-attribute-value value="M"/>
</variation-attribute-values>
</variation-attribute>

Input XML:
The product node gets repeated multiple times:
<PRODUCT>
<SUPPLIER_PID>sku30101</SUPPLIER_PID>
<PRODUCT_DETAILS>
<DESCRIPTION_SHORT>-</DESCRIPTION_SHORT>
<DESCRIPTION_LONG>-</DESCRIPTION_LONG>
<BUYER_PID type='GTIN'>-</BUYER_PID>
<BUYER_PID type="ARTICLETYPE">clothing-sku</BUYER_PID>
<BUYER_PID type="ONLINEONLY">-</BUYER_PID>
<BUYER_PID type="DISCOUNTABLE">-</BUYER_PID>
<BUYER_PID type="TAXSTATUS">-</BUYER_PID>
<BUYER_PID type="ONSALE">-</BUYER_PID>
<BUYER_PID type="STARTDATE">-</BUYER_PID>
<BUYER_PID type="ENDDATE">-</BUYER_PID>
<BUYER_PID type="UNITOFMEASURE">-</BUYER_PID>
<BUYER_PID type="DISPLAYNAME">Weekend T-Shirt</BUYER_PID>
<BUYER_PID type="FULFILLER">-</BUYER_PID>
<BUYER_PID type="TRANSLATIONS">de,es</BUYER_PID>
</PRODUCT_DETAILS>
<PRODUCT_FEATURES>
<FEATURE>
<FTEMPLATE>
<FT_ID>1425380474637</FT_ID>
<FT_NAME>Size</FT_NAME>
<FT_SHORTNAME>Size</FT_SHORTNAME>
<FT_DESCR>-</FT_DESCR>
</FTEMPLATE>
<FVALUE>L</FVALUE>
</FEATURE>
<FEATURE>
<FTEMPLATE>
<FT_ID>1425380474636</FT_ID>
<FT_NAME>Color</FT_NAME>
<FT_SHORTNAME>Color</FT_SHORTNAME>
<FT_DESCR>-</FT_DESCR>
</FTEMPLATE>
<FVALUE>Green</FVALUE>
</FEATURE>

</PRODUCT_FEATURES>
<PRODUCT_ORDER_DETAILS>
<ORDER_UNIT></ORDER_UNIT>
<PRICE_QUANTITY>1.0000</PRICE_QUANTITY>
<QUANTITY_MIN>1.0000</QUANTITY_MIN>
<QUANTITY_INTERVAL>1.00</QUANTITY_INTERVAL>
</PRODUCT_ORDER_DETAILS>
<PRODUCT_PRICE_DETAILS>
<DATETIME type="valid_start_date">
<DATE>2015-08-26</DATE>
</DATETIME>
<DAILY_PRICE>false</DAILY_PRICE>



<PRODUCT_PRICE price_type="udp_listprice">
<PRICE_AMOUNT>19.99</PRICE_AMOUNT>
<PRICE_CURRENCY>USD</PRICE_CURRENCY>
<PRICE_FACTOR>1</PRICE_FACTOR>
<LOWER_BOUND>1</LOWER_BOUND>
<TERRITORY></TERRITORY>
</PRODUCT_PRICE>
<PRODUCT_PRICE price_type="udp_listprice">
<PRICE_AMOUNT>25.99</PRICE_AMOUNT>
<PRICE_CURRENCY>EUR</PRICE_CURRENCY>
<PRICE_FACTOR>1</PRICE_FACTOR>
<LOWER_BOUND>1</LOWER_BOUND>
<TERRITORY>DE</TERRITORY>
</PRODUCT_PRICE>


</PRODUCT_PRICE_DETAILS>
<PRODUCT_REFERENCE type="base_product">
<PROD_ID_TO>prod10007</PROD_ID_TO>
</PRODUCT_REFERENCE>

</PRODUCT>

XSL:



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl" xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="str">
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<!-- <xsl:value-of select="concat(concat(substring-before($text,$replace),'='),substring-before($text,$replace))" /> -->
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

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

<xsl:template match="BMECAT">
<xsl:variable name="pr-cg_map">
<map>
<xsl:for-each select="T_NEW_CATALOG/PRODUCT_TO_CATALOGGROUP_MAP">
<entry>
<xsl:attribute name="key">
<xsl:value-of select="PROD_ID"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="CATALOG_GROUP_ID"></xsl:value-of>
</entry>
</xsl:for-each>
</map>
</xsl:variable>
<xsl:text> </xsl:text>
<xsl:text disable-output-escaping="yes">&lt;catalog xmlns="http://www.demandware.com/xml/impex/catalog/2006-10-31" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.demandware.com/xml/impex/catalog/2006-10-31 catalog.xsd" catalog-id="storefront-catalog-en"&gt;</xsl:text>

<xsl:text> </xsl:text>
<xsl:variable name="viewType_Large" select="'large'"/>
<xsl:variable name="viewType_Medium" select="'medium'"/>
<xsl:variable name="viewType_Small" select="'small'"/>
<xsl:variable name="viewType_Swatch" select="'swatch'"/>
<xsl:variable name="imageType_Large" select="'Large'"/>
<xsl:variable name="imageType_Full" select="'Full'"/>
<xsl:variable name="imageType_Medium" select="'Medium'"/>
<xsl:variable name="imageType_Small" select="'Small'"/>
<xsl:variable name="imageType_Thumbnail" select="'Thumbnail'"/>
<xsl:variable name="imageBasePath" select="'/image'"/>
<xsl:variable name="varAttId" select="'color'"/>
<xsl:variable name="altPatter" select="'${productname}, ${variationvalue}, ${viewtype}'"/>
<xsl:variable name="titlePattern" select="'${productname}, ${variationvalue}'"/>
<xsl:variable name="productBrand"><xsl:value-of select="T_NEW_CATALOG/CLASSIFICATION_SYSTEM/CLASSIFICATION_SYSTEM_DESCR"/></xsl:variable>
<xsl:variable name="skuBrand"><xsl:value-of select="'Itemsstore'"/></xsl:variable>
<xsl:variable name="furnitureSkuBrand"><xsl:value-of select="'Furniturestore'"/></xsl:variable>
<xsl:variable name="clothingSkuBrand"><xsl:value-of select="'Apparelstore'"/></xsl:variable>
<xsl:variable name="imagePath" select="'hlr-system/Oracle ATG/products/'"/>

<xsl:comment>Header Data starts Here</xsl:comment><xsl:text> </xsl:text>
<xsl:element name="header"><xsl:text> </xsl:text>
<xsl:element name="image-settings"><xsl:text> </xsl:text>
<xsl:element name="internal-location">
<xsl:attribute name="base-location">
<xsl:value-of select="$imageBasePath"/>
</xsl:attribute>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:element name="view-types"><xsl:text> </xsl:text>
<xsl:element name="view-type">
<xsl:value-of select="$viewType_Large"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="view-type">
<xsl:value-of select="$viewType_Swatch"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="view-type">
<xsl:value-of select="$viewType_Medium"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="view-type">
<xsl:value-of select="$viewType_Small"/>
</xsl:element><xsl:text> </xsl:text>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="variation-attribute-id">
<xsl:value-of select="$varAttId"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="alt-pattern">
<xsl:value-of select="$altPatter"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="title-pattern">
<xsl:value-of select="$titlePattern"/>
</xsl:element><xsl:text> </xsl:text>

</xsl:element> <xsl:text> </xsl:text>
</xsl:element><xsl:text> </xsl:text>
<xsl:comment>Header Data ends Here</xsl:comment><xsl:text> </xsl:text>

<xsl:comment>Product Data starts Here</xsl:comment><xsl:text> </xsl:text>
<xsl:variable name="catalog" select="./T_NEW_CATALOG"/>
<xsl:for-each select="T_NEW_CATALOG/PRODUCT[./PRODUCT_DETAILS/BUYER_PID[@type='PRODUCTTYPE']='Product']">
<xsl:if test="PRODUCT_DETAILS/BUYER_PID[@type='PRODUCTTYPE']='Product'">
<!-- <xsl:if test="SUPPLIER_PID='prod10007'"> -->
<xsl:variable name="prodID"><xsl:value-of select="SUPPLIER_PID"/></xsl:variable>
<xsl:variable name="displayName"><xsl:value-of select="PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME']"/></xsl:variable>
<xsl:element name="product">
<xsl:attribute name="product-id">
<xsl:value-of select="SUPPLIER_PID"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="ean">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="upc">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="unit">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="min-order-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_MIN"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="step-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_INTERVAL"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="display-name">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME']"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="short-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_SHORT"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="long-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_LONG"/>
</xsl:element> <xsl:text> </xsl:text>
<xsl:element name="online-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="available-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="searchable-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="images"><xsl:text> </xsl:text>
<xsl:for-each select="MIME_INFO/MIME">
<xsl:element name="image-group">
<xsl:attribute name="view-type">
<xsl:value-of select="MIME_TYPE"/>
</xsl:attribute><xsl:text> </xsl:text>
<xsl:element name="image">
<xsl:attribute name="path">
<xsl:value-of select="concat($imagePath,MIME_SOURCE)"/>
</xsl:attribute>
</xsl:element><xsl:text> </xsl:text>
</xsl:element><xsl:text> </xsl:text> <!-- image-group -->
</xsl:for-each>

</xsl:element> <xsl:text> </xsl:text> <!-- images -->
<xsl:element name="tax-class-id"><xsl:value-of select="'standard'"/></xsl:element><xsl:text> </xsl:text> <!-- tax-class-id -->
<xsl:element name="brand"><xsl:value-of select="$productBrand"/></xsl:element><xsl:text> </xsl:text> <!-- brand -->

<xsl:element name="page-attributes">
<xsl:text> </xsl:text>
<xsl:element name="page-title">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="concat((concat($productBrand,' - ')),PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME'])"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_SHORT"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-keywords">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_ID='Keywords'">
<xsl:choose>
<xsl:when test="FVALUE!='-'">
<xsl:variable name="replacedText">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="FVALUE" />
<xsl:with-param name="replace" select="','" />
<xsl:with-param name="by" select="';'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$replacedText"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(FVALUE,'-','')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-url">
<xsl:for-each select="exsl:node-set($pr-cg_map)/map/entry[@key=$prodID][position()=1]">
<xsl:variable name="catalogId"><xsl:value-of select="." /> </xsl:variable>
<xsl:value-of select="concat(concat($catalogId,' - '),$displayName)"/>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text>
</xsl:element> <!-- page attributes -->
<xsl:text> </xsl:text>

<xsl:element name="variations"><xsl:text> </xsl:text>
<xsl:element name="attributes"> <xsl:text> </xsl:text>


<!-- This block can be repeated for any number of attributes starts -->
<xsl:element name="variation-attribute">
<xsl:attribute name ="attribute-id"> <xsl:value-of select="'Size'"/></xsl:attribute>
<xsl:attribute name="variation-attribute-id"><xsl:value-of select="'Size'"/></xsl:attribute><xsl:text> </xsl:text>
<xsl:element name="display-name">
<xsl:attribute name="xml:lang"><xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:text>Size</xsl:text>
</xsl:element> <xsl:text> </xsl:text>
<xsl:element name="variation-attribute-values"> <xsl:text> </xsl:text>
<xsl:for-each select="$catalog/PRODUCT[./PRODUCT_REFERENCE/PROD_ID_TO=$prodID]">
<!-- <xsl:value-of select="./PRODUCT_FEATURES/FEATURE/FVALUE"/> -->
<xsl:for-each select="./PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Size'">
<!-- <xsl:if test="not(following::Request[FVALUE=current()])"> -->
<xsl:element name="variation-attribute-value">
<xsl:attribute name="value">
<xsl:value-of select="FVALUE"/>
</xsl:attribute>
<xsl:text></xsl:text>
</xsl:element> <!-- variation attribute value --> <xsl:text> </xsl:text>
<!-- </xsl:if> -->
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:element> <!-- variation attribute values --><xsl:text> </xsl:text>
</xsl:element> <!-- variation attribute --><xsl:text> </xsl:text>
<!-- This block can be repeated for any number of attributes ends -->


<!-- This block can be repeated for any number of attributes starts -->
<xsl:element name="variation-attribute">
<xsl:attribute name ="attribute-id"> <xsl:value-of select="'Color'"/></xsl:attribute>
<xsl:attribute name="variation-attribute-id"><xsl:value-of select="'Color'"/></xsl:attribute><xsl:text> </xsl:text>
<xsl:element name="variation-attribute-values"> <xsl:text> </xsl:text>
<xsl:for-each select="$catalog/PRODUCT[./PRODUCT_REFERENCE/PROD_ID_TO=$prodID]">
<!-- <xsl:value-of select="./PRODUCT_FEATURES/FEATURE/FVALUE"/> -->
<xsl:for-each select="./PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Color'">
<xsl:element name="variation-attribute-value">
<xsl:attribute name="value">
<xsl:value-of select="FVALUE"/>
</xsl:attribute>
</xsl:element> <!-- variation attribute value --> <xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each> <xsl:text> </xsl:text>
</xsl:element> <!-- variation attribute values --><xsl:text> </xsl:text>
</xsl:element> <!-- variation attribute --><xsl:text> </xsl:text>
<!-- This block can be repeated for any number of attributes ends -->


</xsl:element><xsl:text> </xsl:text> <!-- attributes -->


<!-- child items of the product -->
<xsl:element name="variants"><xsl:text> </xsl:text>
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='childSKUs'">
<xsl:variable name="childSku" select='FVALUE'/>
<xsl:for-each select="str:tokenize($childSku,',')">
<xsl:element name="variant">
<xsl:attribute name="product-id">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:element><xsl:text> </xsl:text>
</xsl:for-each><xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:element> <xsl:text> </xsl:text> <!-- variants -->


</xsl:element> <xsl:text> </xsl:text> <!-- Variations -->

<xsl:element name="classification-category">
<xsl:for-each select="exsl:node-set($pr-cg_map)/map/entry[@key=$prodID][position()=1]">
<xsl:variable name="catalogId"><xsl:value-of select="." /> </xsl:variable>
<xsl:value-of select="$catalogId"/> <!-- classification-category -->
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text> <!-- classification-category -->

</xsl:element> <!-- product --><xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:comment>Product Data ends Here</xsl:comment>

<xsl:comment>Sku Data starts Here</xsl:comment><xsl:text> </xsl:text>

<!-- <xsl:for-each select="T_NEW_CATALOG/PRODUCT">
<xsl:if test="PRODUCT_DETAILS/BUYER_PID[@type='ARTICLETYPE']='furniture-sku'">
<xsl:if test="SUPPLIER_PID='xprod2095'">
<xsl:text> </xsl:text>
<xsl:element name="product">
<xsl:attribute name="product-id">
<xsl:value-of select="SUPPLIER_PID"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="ean">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="upc">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="unit">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="min-order-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_MIN"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="step-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_INTERVAL"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="online-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="available-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="searchable-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="tax-class-id"><xsl:value-of select="'standard'"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="brand"><xsl:value-of select="$furnitureSkuBrand"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-attributes">
<xsl:text> </xsl:text>
<xsl:element name="page-title">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="concat((concat($furnitureSkuBrand' - ')),PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME'])"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_SHORT"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-keywords">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_ID='Keywords'">
<xsl:choose>
<xsl:when test="FVALUE!='-'">
<xsl:variable name="replacedText">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="FVALUE" />
<xsl:with-param name="replace" select="','" />
<xsl:with-param name="by" select="';'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$replacedText"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(FVALUE,'-','')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text>
</xsl:element> page attributes
<xsl:text> </xsl:text>
<xsl:element name="custom-attributes">
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Size'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Color'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="T_NEW_CATALOG/PRODUCT">
<xsl:if test="PRODUCT_DETAILS/BUYER_PID[@type='ARTICLETYPE']='Sku'">
<xsl:if test="SUPPLIER_PID='xprod2095'">
<xsl:text> </xsl:text>
<xsl:element name="product">
<xsl:attribute name="product-id">
<xsl:value-of select="SUPPLIER_PID"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="ean">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="upc">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="unit">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="min-order-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_MIN"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="step-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_INTERVAL"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="online-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="available-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="searchable-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="tax-class-id"><xsl:value-of select="'standard'"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="brand"><xsl:value-of select="$clothingSkuBrand"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-attributes">
<xsl:text> </xsl:text>
<xsl:element name="page-title">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="concat((concat($clothingSkuBrand' - ')),PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME'])"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_SHORT"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-keywords">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_ID='Keywords'">
<xsl:choose>
<xsl:when test="FVALUE!='-'">
<xsl:variable name="replacedText">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="FVALUE" />
<xsl:with-param name="replace" select="','" />
<xsl:with-param name="by" select="';'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$replacedText"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(FVALUE,'-','')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text>
</xsl:element> page attributes
<xsl:text> </xsl:text>
<xsl:element name="custom-attributes">
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Size'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Color'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each> -->
<xsl:for-each select="T_NEW_CATALOG/PRODUCT">
<xsl:if test="PRODUCT_DETAILS/BUYER_PID[@type='ARTICLETYPE']='clothing-sku'">
<!-- <xsl:if test="SUPPLIER_PID='xprod2095'"> -->
<xsl:text> </xsl:text>
<xsl:element name="product">
<xsl:attribute name="product-id">
<xsl:value-of select="SUPPLIER_PID"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="ean">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="upc">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="unit">
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="min-order-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_MIN"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="step-quantity">
<xsl:value-of select="PRODUCT_ORDER_DETAILS/QUANTITY_INTERVAL"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="online-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="available-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="searchable-flag">
<xsl:choose>
<xsl:when test="PRODUCT_DETAILS/BUYER_PID[@type='ONLINEONLY']!='-'">
<xsl:value-of select="'true'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'" />
</xsl:otherwise>
</xsl:choose>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="tax-class-id"><xsl:value-of select="'standard'"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="brand"><xsl:value-of select="$skuBrand"/></xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-attributes">
<!-- <xsl:text> </xsl:text>
<xsl:element name="page-title">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="concat((concat($skuBrand,' - ')),PRODUCT_DETAILS/BUYER_PID[@type='DISPLAYNAME'])"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-description">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:value-of select="PRODUCT_DETAILS/DESCRIPTION_SHORT"/>
</xsl:element><xsl:text> </xsl:text>
<xsl:element name="page-keywords">
<xsl:attribute name="xml:lang"> <xsl:value-of select="'x-default'"/></xsl:attribute>
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_ID='Keywords'">
<xsl:choose>
<xsl:when test="FVALUE!='-'">
<xsl:variable name="replacedText">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="FVALUE" />
<xsl:with-param name="replace" select="','" />
<xsl:with-param name="by" select="';'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$replacedText"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate(FVALUE,'-','')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text> -->
</xsl:element> <!-- page attributes -->
<xsl:text> </xsl:text>
<xsl:element name="custom-attributes">
<xsl:for-each select="PRODUCT_FEATURES/FEATURE">
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Size'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
<xsl:if test="FTEMPLATE/FT_SHORTNAME='Color'">
<xsl:element name="custom-attribute">
<xsl:attribute name="attribute-id" select="FTEMPLATE/FT_SHORTNAME"></xsl:attribute>
<xsl:value-of select="FVALUE"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element><xsl:text> </xsl:text>
</xsl:element><xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each><xsl:text> </xsl:text>
<xsl:comment>Sku Data ends Here</xsl:comment><xsl:text> </xsl:text>
<xsl:text disable-output-escaping="yes">&lt;/catalog&gt;</xsl:text>
</xsl:template>
</xsl:stylesheet>





Similar Threads
Thread Thread Starter Forum Replies Last Post
unique values Vision G Access VBA 1 December 19th, 2011 09:55 AM
Loop twice, then inside loop select nodes?? JohnBampton XSLT 2 March 9th, 2009 05:21 AM
How to loop for Select Values rohit_ghosh Excel VBA 3 May 8th, 2007 03:29 PM
loop values and text box values move mateenmohd Classic ASP Basics 2 April 5th, 2005 11:33 PM
Unique Control IDs inside a loop using a varible Joshua Sebastian Classic ASP Basics 2 February 3rd, 2005 10:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.