I am an XML Newbie, I have an XML output file that list each "Item" for each "Qty". For example, if item "B42" QTY=2, the XML file will list it 2 times with QTY=1 instead of listing it once with QTY=2.
DUE TO THIS HEADACH, is there a way to count/add the quantities? <<<preferred method>>>
If there is no way to count/add, is there a way to sort the output?
Below is the code and the source. I've tried to read and google help, but I cannot get it to work.
I really do not mind in which order it is sorted, just as long as the duplicates are together.
Thank you in advance! -Snug
Output code:
Source XML: (Just 3 items)
XSL:
DUE TO THIS HEADACH, is there a way to count/add the quantities? <<<preferred method>>>
If there is no way to count/add, is there a way to sort the output?
Below is the code and the source. I've tried to read and google help, but I cannot get it to work.
I really do not mind in which order it is sorted, just as long as the duplicates are together.
Thank you in advance! -Snug
Output code:
Code:
0-SB36BUTT|1|789|Cabinets|0|1|
0-B42|1|957|Cabinets|0|12|
{NONE}|0|0|Cabinets|-1|1.1|
0-B42|1|957|Cabinets|0|12|
Source XML: (Just 3 items)
Code:
<Item ID="IDI-1-110">
<UserCode>SB36BUTT</UserCode>
<Quantity>1</Quantity>
<Price Type="Cost" Mode="Fixed" Level="1">
<Value>899</Value>
<FormattedValue><![CDATA[$899.00]]></FormattedValue>
</Price>
<Price Type="List" Mode="Fixed" Level="1">
<Value>899</Value>
<FormattedValue><![CDATA[$899.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="1">
<Value>899</Value>
<FormattedValue><![CDATA[$899.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="2">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Var ID="-2" type="String">
<Value>SB36BUTT</Value>
<Name><![CDATA[PV_FloorPlanCODE]]></Name>
</Var>
<Var ID="-7" type="String">
<Value>0</Value>
<Name><![CDATA[PV_FMTPOSitionSTart]]></Name>
</Var>
<Var ID="-8" type="String">
<Value>36</Value>
<Name><![CDATA[PV_FMTPOSitionEND]]></Name>
</Var>
</Item>
<Item ID="IDI-1-111">
<UserCode><![CDATA[B42]]></UserCode>
<Quantity>1</Quantity>
<Price Type="Cost" Mode="Fixed" Level="1">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="List" Mode="Fixed" Level="1">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="1">
<Value>456</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="2">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Var ID="-9" type="String">
<Value>18</Value>
<Name><![CDATA[PV_FMTPOSitionCENter]]></Name>
</Var>
<Var ID="-2" type="String">
<Value><![CDATA[B42]]></Value>
<Name><![CDATA[PV_FloorPlanCODE]]></Name>
</Var>
<Var ID="-7" type="String">
<Value>0</Value>
<Name><![CDATA[PV_FMTPOSitionSTart]]></Name>
</Var>
<Var ID="-8" type="String">
<Value>36</Value>
<Name><![CDATA[PV_FMTPOSitionEND]]></Name>
</Var>
<Var ID="-12" type="Qty">
<Value>54</Value>
<Name><![CDATA[PV_TYPECAB]]></Name>
</Var>
</Item>
<Item ID="IDI-1-431">
<UserCode><![CDATA[B42]]></UserCode>
<Quantity>1</Quantity>
<Price Type="Cost" Mode="Fixed" Level="1">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="List" Mode="Fixed" Level="1">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="1">
<Value>456</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Price Type="Retail" Mode="Fixed" Level="2">
<Value>0</Value>
<FormattedValue><![CDATA[$0.00]]></FormattedValue>
</Price>
<Var ID="-9" type="String">
<Value>18</Value>
<Name><![CDATA[PV_FMTPOSitionCENter]]></Name>
</Var>
<Var ID="-2" type="String">
<Value><![CDATA[B42]]></Value>
<Name><![CDATA[PV_FloorPlanCODE]]></Name>
</Var>
<Var ID="-7" type="String">
<Value>0</Value>
<Name><![CDATA[PV_FMTPOSitionSTart]]></Name>
</Var>
<Var ID="-8" type="String">
<Value>36</Value>
<Name><![CDATA[PV_FMTPOSitionEND]]></Name>
</Var>
<Var ID="-12" type="Qty">
<Value>54</Value>
<Name><![CDATA[PV_TYPECAB]]></Name>
</Var>
</Item>
Code:
<xsl:template match="Item">
<xsl:if test="ItemTypeName != 'Appliances'">
<xsl:if test="Price[3]/Value=0">
<br>
<xsl:value-of select="Var[@ID='-2']/Value"/>
<xsl:text>|0|0|</xsl:text>
<xsl:value-of select="ItemTypeName"/>
<xsl:text>|-1|</xsl:text>
<xsl:value-of select="LineItemNumber"/>
<xsl:text>|</xsl:text>
</br>
</xsl:if>
<xsl:if test="Price[3]/Value != 0">
<br>
<xsl:for-each select="Item">
<xsl:sort select="Var[@ID='-2']/Value" data-type="number" order="ascending">
</xsl:sort>
</xsl:for-each>
<xsl:value-of select="Var[@ID='-7']/Value"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="Var[@ID='-2']/Value"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="Quantity"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="Price[3]/Value + Price[6]/Value"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="ItemTypeName"/>
<xsl:text>|</xsl:text>
<xsl:choose>
<xsl:when test="SubTypeName = 'Charge'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>|</xsl:text>
<xsl:value-of select="LineItemNumber"/>
<xsl:text>|</xsl:text>
</br>
</xsl:if>
</xsl:if>
</xsl:template>