• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

XSLT for XML returned from two different web services

I have a page that calls two different web services for the same SKU. One returns XML for days in transit and one returns XML for pricing on the different sizes.

Using XSLT, is it possible to combine the two XML files into a table like this?

HTML table output of data
How would I do this using this example for the SKU K500?

Pricing XML:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getPricingResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
         <return>
            <errorOccurred>false</errorOccurred>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>XS</size>
               <sizeIndex>1</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>S</size>
               <sizeIndex>2</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>M</size>
               <sizeIndex>3</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>L</size>
               <sizeIndex>4</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>XL</size>
               <sizeIndex>5</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>8.49</casePrice>
               <color>Banana</color>
               <dozenPrice>9.49</dozenPrice>
               <inventoryKey>24084</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>11.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>2XL</size>
               <sizeIndex>1</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>10.49</casePrice>
               <color>Banana</color>
               <dozenPrice>11.49</dozenPrice>
               <inventoryKey>24085</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>13.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>3XL</size>
               <sizeIndex>2</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>11.49</casePrice>
               <color>Banana</color>
               <dozenPrice>12.49</dozenPrice>
               <inventoryKey>24086</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>14.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>4XL</size>
               <sizeIndex>3</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>13.49</casePrice>
               <color>Banana</color>
               <dozenPrice>14.49</dozenPrice>
               <inventoryKey>24087</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>16.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>5XL</size>
               <sizeIndex>4</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>14.49</casePrice>
               <color>Banana</color>
               <dozenPrice>15.49</dozenPrice>
               <inventoryKey>24088</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>17.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>6XL</size>
               <sizeIndex>5</sizeIndex>
               <style>K500</style>
            </listResponse>
            <message>Pricing returned successfully</message>
         </return>
      </ns2:getPricingResponse>
   </S:Body>
</S:Envelope>

Open in new window


Days in transit XML:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getPricingResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
         <return>
            <errorOccurred>false</errorOccurred>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>XS</size>
               <sizeIndex>1</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>S</size>
               <sizeIndex>2</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>M</size>
               <sizeIndex>3</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>L</size>
               <sizeIndex>4</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>7.49</casePrice>
               <color>Banana</color>
               <dozenPrice>8.49</dozenPrice>
               <inventoryKey>24083</inventoryKey>
               <myPrice>7.49</myPrice>
               <piecePrice>10.49</piecePrice>
               <size>XL</size>
               <sizeIndex>5</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>8.49</casePrice>
               <color>Banana</color>
               <dozenPrice>9.49</dozenPrice>
               <inventoryKey>24084</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>11.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>2XL</size>
               <sizeIndex>1</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>10.49</casePrice>
               <color>Banana</color>
               <dozenPrice>11.49</dozenPrice>
               <inventoryKey>24085</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>13.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>3XL</size>
               <sizeIndex>2</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>11.49</casePrice>
               <color>Banana</color>
               <dozenPrice>12.49</dozenPrice>
               <inventoryKey>24086</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>14.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>4XL</size>
               <sizeIndex>3</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>13.49</casePrice>
               <color>Banana</color>
               <dozenPrice>14.49</dozenPrice>
               <inventoryKey>24087</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>16.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>5XL</size>
               <sizeIndex>4</sizeIndex>
               <style>K500</style>
            </listResponse>
            <listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <casePrice>14.49</casePrice>
               <color>Banana</color>
               <dozenPrice>15.49</dozenPrice>
               <inventoryKey>24088</inventoryKey>
               <myPrice>6.79</myPrice>
               <piecePrice>17.49</piecePrice>
               <salePrice>6.79</salePrice>
               <size>6XL</size>
               <sizeIndex>5</sizeIndex>
               <style>K500</style>
            </listResponse>
            <message>Pricing returned successfully</message>
         </return>
      </ns2:getPricingResponse>
   </S:Body>
</S:Envelope>

Open in new window

0
P-Daddy
Asked:
P-Daddy
  • 29
  • 28
1 Solution
 
Geert BormansCommented:
Do you realize that you posted the same XML twice?
0
 
P-DaddyAuthor Commented:
I sure did!

Here's the transit XML:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getInventoryDaysInTransitResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
         <return>
            <errorOccured>false</errorOccured>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>500</quantity>
               <size>2XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>2XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>434</quantity>
               <size>2XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>166</quantity>
               <size>3XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>3XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>177</quantity>
               <size>3XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>246</quantity>
               <size>4XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>91</quantity>
               <size>4XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>76</quantity>
               <size>4XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>45</quantity>
               <size>5XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>130</quantity>
               <size>5XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>29</quantity>
               <size>5XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>70</quantity>
               <size>6XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>24</quantity>
               <size>6XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>31</quantity>
               <size>6XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>0</quantity>
               <size>M</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>M</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>M</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>S</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>S</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>500</quantity>
               <size>S</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>1</daysInTransit>
               <quantity>0</quantity>
               <size>XS</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>4</daysInTransit>
               <quantity>500</quantity>
               <size>XS</size>
               <style>K500</style>
            </listResponse>
            <listResponse>
               <color>Banana</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>XS</size>
               <style>K500</style>
            </listResponse>
            <message>Inventory returned successfully.</message>
         </return>
      </ns2:getInventoryDaysInTransitResponse>
   </S:Body>
</S:Envelope>

Open in new window

0
 
Geert BormansCommented:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:map="#internal"
    version="1.0">
    
    <xsl:variable name="doc" select="/"/>
    <xsl:variable name="t-doc" select="document('transit.xml')"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table>
                    <tr>
                        <th></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <th><xsl:value-of select="."/></th>
                        </xsl:for-each>
                     </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'dozenPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'piecePrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>2XL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
</xsl:stylesheet>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Geert BormansCommented:
to note

- the input xml for the XSLT is the prices XML
- the other XML is called using the document function, so you need to make sure the path is correct: document('transit.xml')

- since you need to enable the document function anyway, the cool thing is that you can have a mapping file in the XSLT that serves as a lookup for all the availables sizes, in the right order

- I did the lookup without a key... that would be another option for bigger file sizes
0
 
P-DaddyAuthor Commented:
Thank you Geert!

Before I would load the (transit) XML and display the formatted table using:

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
objXML.load(oXmlHTTP.responseXML)

Set objXSLT = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXSLT.async = False
objXSLT.load("http://www.sportsupplygroup.com/Sanmar/transit.xsl")

Set objTpl = Server.CreateObject("MSXML2.XSLTemplate")
objTpl.stylesheet = objXSLT

Set objProc = objTpl.createProcessor()
objProc.input = objXML
objProc.transform()

objProc.output

Open in new window


How would I go about this using your code where you're pointing to transit.xml?
0
 
P-DaddyAuthor Commented:
Here's my code and how I load the pricing XML. "output.xsl" is the code you provided which when I run, I see the transit come through in the table data but all the pricing is blank.

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
objXML.load(oXmlHTTP.responseXML)

Set objXSLT = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXSLT.async = False
objXSLT.load("http://www.sportsupplygroup.com/Sanmar/output.xsl")

Set objTpl = Server.CreateObject("MSXML2.XSLTemplate")
objTpl.stylesheet = objXSLT

Set objProc = objTpl.createProcessor()
objProc.input = objXML
objProc.transform()
objProc.output

Open in new window


So would this line need to change in the XSL file?

<xsl:variable name="doc" select="/"/>

Open in new window


I still need to find a way to load the transit XML from the web service and not path in XSL.
0
 
Geert BormansCommented:
Hi, just returned home but off to bed now, wil look into this in the morning
0
 
Geert BormansCommented:
I think it would be more elegant if you would pass the location of the transit document as a parameter

replace this

   <xsl:variable name="t-doc" select="document('transit.xml')"/>

with

   <xsl:param name="transitdoc" select="'transit.xml'"/>
   <xsl:variable name="t-doc" select="document($transitdoc)"/>

After you have done that, pass the parameter like this

Set objProc = objTpl.createProcessor()
objProc.input = objXML

to become

Set objProc = objTpl.createProcessor()
objProc.addParameter "transitdoc", "http://www.sportsupplygroup.com/Sanmar/transit.xml"
objProc.input = objXML

having the transit.xml on a server and pass the url to tha transitdoc is easiest actually
file systems might require some trial and error to get the file loaded

I also think you should set the "AllowDocumentFunction" property to true when loading the XSLT

Set objXSLT = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")

to become

Set objXSLT = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXSLT.setProperty("AllowDocumentFunction", true)

after that, it should work
0
 
P-DaddyAuthor Commented:
Today, transit.xml does not exist as a file. I call a web service and load the transit xml using

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
objXML.load(oXmlHTTP.responseXML)

Is there a way to do this without having to save a file called transit.xml on the server?

Hope that make sense.
0
 
Geert BormansCommented:
is that a REST service?
then the request would have it's own URL, and you pass that URL as the parameter

what about prices.xml? Is that a file? We could reverse the logic if that is

There are various things we can do, but maybe this makes most sense
We could make an XML document, add a root as a wrapperand after that add both documents to the root element... and pass that as the source to the XSLT
0
 
P-DaddyAuthor Commented:
Yeah both are SOAP requests.  I will post code tomorrow when back in the office.

Thanks for help.
0
 
Geert BormansCommented:
hmm, SOAP requires payload in the request body, that is hard to fix from withing XSLT.
Recommended approach is likely to combine the two SOAP responses into one big XML and pass that to the XSLT.
Can you do that?
0
 
P-DaddyAuthor Commented:
User comes to web page and selects a sku, color option, and enters zip code. sku and color values are passed to pricing API web service and sku, color, zip are passed to a different API web service for transit info. The goal is to take the data (XML)  from both services and show in the table like in original post.


Request to get pricing:

Set oXmlHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
oXmlHTTP.Open "POST", "https://lincoln.sanmar.com:8080/SanMarWebService/getPricing?WSDL", False 
oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "SOAPAction", ""
SOAPRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:impl=""http://impl.webservice.integration.sanmar.com/"">" _
& "<soapenv:Header/>" _
& "<soapenv:Body>" _
& "<impl:getPricing>" _
& "<arg0>" _
& "<style>"&sku&"</style>" _
& "<color>"&color&"</color>" _
& "<size></size>" _
& "<inventoryKey></inventoryKey>" _
& "<sizeIndex></sizeIndex>" _
& "<piecePrice></piecePrice>" _
& "<dozenPrice></dozenPrice>" _
& "<casePrice></casePrice>" _
& "<salePrice></salePrice>" _
& "<myPrice></myPrice>" _
& "</arg0>" _
& "<arg1>" _
& "<sanMarCustomerNumber>150963</sanMarCustomerNumber>" _
& "<sanMarUserName>alangford</sanMarUserName>" _
& "<sanMarUserPassword>sanmar</sanMarUserPassword>" _
& "<senderId>?</senderId>" _
& "<senderPassword>?</senderPassword>" _
& "</arg1>" _
& "</impl:getPricing>" _
& "</soapenv:Body>" _
& "</soapenv:Envelope>" 
oXmlHTTP.send SOAPRequest    

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
objXML.load(oXmlHTTP.responseXML)

Open in new window




Request to get transit info:

Set oXmlHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
oXmlHTTP.Open "POST", "https://lincoln.sanmar.com:8080/SanMarWebService/InventoryDaysInTransitWSPort?WSDL", False 
oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "SOAPAction", ""
SOAPRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:impl=""http://impl.webservice.integration.sanmar.com/"">" _
& "<soapenv:Header/>" _
& "<soapenv:Body>" _
& "<impl:getInventoryDaysInTransit>" _
& "<arg0>" _
& "<style>"&sku&"</style>" _
& "<color>"&color&"</color>" _
& "<size></size>" _
& "<sanmarCustomerNumber>150963</sanmarCustomerNumber>" _
& "<sanmarUserName>alangford</sanmarUserName>" _
& "<sanmarPassword>sanmar</sanmarPassword>" _
& "<shipToPostalCode>"&zp&"</shipToPostalCode>" _
& "</arg0>" _
& "</impl:getInventoryDaysInTransit>" _
& "</soapenv:Body>" _
& "</soapenv:Envelope>" 
oXmlHTTP.send SOAPRequest  

Set objXML = Server.CreateObject("MSXML2.DOMDocument")
objXML.async = False
objXML.load(oXmlHTTP.responseXML)

Open in new window


How do I combine the two and use your XSLT template to display?
0
 
Geert BormansCommented:
// pricing
Set objXMLp = Server.CreateObject("MSXML2.DOMDocument")
objXMLp.async = False
objXMLp.load(oXmlPricingHTTP.responseXML)

//transit
Set objXMLt = Server.CreateObject("MSXML2.DOMDocument")
objXMLt.async = False
objXMLt.load(oXmlTransitHTTP.responseXML)

set tnodes = objXMLt.selectNodes("/*/*")

for each node in tnodes
     objXMLp.documentElement.appendChild node
next

and then you can pass objXMLp to the XSLT,
we need to change the XSLT then however
but first try to give me an example of the resulting objXMLp
0
 
P-DaddyAuthor Commented:
Here's my code and the error below.

'PRICING API CALL
'***************************************
'***************************************
'***************************************
Set oXmlPricingHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
oXmlPricingHTTP.Open "POST", "https://lincoln.sanmar.com:8080/SanMarWebService/getPricing?WSDL", False 
oXmlPricingHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlPricingHTTP.setRequestHeader "SOAPAction", ""
SOAPRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:impl=""http://impl.webservice.integration.sanmar.com/"">" _
& "<soapenv:Header/>" _
& "<soapenv:Body>" _
& "<impl:getPricing>" _
& "<arg0>" _
& "<style>"&sku&"</style>" _
& "<color>"&color&"</color>" _
& "<size></size>" _
& "<inventoryKey></inventoryKey>" _
& "<sizeIndex></sizeIndex>" _
& "<piecePrice></piecePrice>" _
& "<dozenPrice></dozenPrice>" _
& "<casePrice></casePrice>" _
& "<salePrice></salePrice>" _
& "<myPrice></myPrice>" _
& "</arg0>" _
& "<arg1>" _
& "<sanMarCustomerNumber>150963</sanMarCustomerNumber>" _
& "<sanMarUserName>alangford</sanMarUserName>" _
& "<sanMarUserPassword>sanmar</sanMarUserPassword>" _
& "<senderId>?</senderId>" _
& "<senderPassword>?</senderPassword>" _
& "</arg1>" _
& "</impl:getPricing>" _
& "</soapenv:Body>" _
& "</soapenv:Envelope>" 
oXmlPricingHTTP.send SOAPRequest   
 
Set objXMLp = Server.CreateObject("MSXML2.DOMDocument")
objXMLp.async = False
objXMLp.load(oXmlPricingHTTP.responseXML)

'***************************************
'***************************************
'***************************************


'TRANSIT API CALL
'***************************************
'***************************************
'***************************************
Set oXmlTransitHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
oXmlTransitHTTP.Open "POST", "https://lincoln.sanmar.com:8080/SanMarWebService/InventoryDaysInTransitWSPort?WSDL", False 
oXmlTransitHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlTransitHTTP.setRequestHeader "SOAPAction", ""
SOAPRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:impl=""http://impl.webservice.integration.sanmar.com/"">" _
& "<soapenv:Header/>" _
& "<soapenv:Body>" _
& "<impl:getInventoryDaysInTransit>" _
& "<arg0>" _
& "<style>"&sku&"</style>" _
& "<color>"&color&"</color>" _
& "<size></size>" _
& "<sanmarCustomerNumber>150963</sanmarCustomerNumber>" _
& "<sanmarUserName>alangford</sanmarUserName>" _
& "<sanmarPassword>sanmar</sanmarPassword>" _
& "<shipToPostalCode>"&zp&"</shipToPostalCode>" _
& "</arg0>" _
& "</impl:getInventoryDaysInTransit>" _
& "</soapenv:Body>" _
& "</soapenv:Envelope>" 
oXmlTransitHTTP.send SOAPRequest

Set objXMLt = Server.CreateObject("MSXML2.DOMDocument")
objXMLt.async = False
objXMLt.load(oXmlTransitHTTP.responseXML)
'***************************************
'***************************************
'***************************************


set tnodes = objXMLt.selectNodes("/*/*")

for each node in tnodes
     objXMLp.documentElement.appendChild node
next

Open in new window


Microsoft VBScript runtime error '800a01a8'

Object required: '[object]'

/sanmar/sanmarRequest.asp, line 237

line 237 is

 objXMLp.documentElement.appendChild node

Open in new window

0
 
P-DaddyAuthor Commented:
Also, to output the resulting objXMLp  I can just save like this, correct?

objXMLp.load(oXmlPricingHTTP.responseXML)

objXMLp.save("D:\Inetpub\SportSupplyGroup\wwwroot\Sanmar\objXMLp_output.xml")

Open in new window

0
 
Geert BormansCommented:
did you load the objXMLp already at that point?
seems to be empty
0
 
Geert BormansCommented:
mmh, I am not sure about the save action, am not that familiar with ASP
0
 
P-DaddyAuthor Commented:
I was able to fix the error and output objXMLp.

Here's the XML of objXMLp:

<?xml version="1.0"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getPricingResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/"><return><errorOccurred>false</errorOccurred><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>7.49</casePrice><color>Maroon</color><dozenPrice>8.49</dozenPrice><inventoryKey>45269</inventoryKey><myPrice>7.49</myPrice><piecePrice>10.49</piecePrice><size>XS</size><sizeIndex>1</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>7.49</casePrice><color>Maroon</color><dozenPrice>8.49</dozenPrice><inventoryKey>45269</inventoryKey><myPrice>7.49</myPrice><piecePrice>10.49</piecePrice><size>S</size><sizeIndex>2</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>7.49</casePrice><color>Maroon</color><dozenPrice>8.49</dozenPrice><inventoryKey>45269</inventoryKey><myPrice>7.49</myPrice><piecePrice>10.49</piecePrice><size>M</size><sizeIndex>3</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>7.49</casePrice><color>Maroon</color><dozenPrice>8.49</dozenPrice><inventoryKey>45269</inventoryKey><myPrice>7.49</myPrice><piecePrice>10.49</piecePrice><size>L</size><sizeIndex>4</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>7.49</casePrice><color>Maroon</color><dozenPrice>8.49</dozenPrice><inventoryKey>45269</inventoryKey><myPrice>7.49</myPrice><piecePrice>10.49</piecePrice><size>XL</size><sizeIndex>5</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>8.49</casePrice><color>Maroon</color><dozenPrice>9.49</dozenPrice><inventoryKey>45270</inventoryKey><myPrice>6.79</myPrice><piecePrice>11.49</piecePrice><salePrice>6.79</salePrice><size>2XL</size><sizeIndex>1</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>10.49</casePrice><color>Maroon</color><dozenPrice>11.49</dozenPrice><inventoryKey>45271</inventoryKey><myPrice>6.79</myPrice><piecePrice>13.49</piecePrice><salePrice>6.79</salePrice><size>3XL</size><sizeIndex>2</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>11.49</casePrice><color>Maroon</color><dozenPrice>12.49</dozenPrice><inventoryKey>45272</inventoryKey><myPrice>6.79</myPrice><piecePrice>14.49</piecePrice><salePrice>6.79</salePrice><size>4XL</size><sizeIndex>3</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>13.49</casePrice><color>Maroon</color><dozenPrice>14.49</dozenPrice><inventoryKey>45273</inventoryKey><myPrice>6.79</myPrice><piecePrice>16.49</piecePrice><salePrice>6.79</salePrice><size>5XL</size><sizeIndex>4</sizeIndex><style>K500</style></listResponse><listResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:item"><casePrice>14.49</casePrice><color>Maroon</color><dozenPrice>15.49</dozenPrice><inventoryKey>45274</inventoryKey><myPrice>6.79</myPrice><piecePrice>17.49</piecePrice><salePrice>6.79</salePrice><size>6XL</size><sizeIndex>5</sizeIndex><style>K500</style></listResponse><message>Pricing returned successfully</message></return></ns2:getPricingResponse></S:Body><S:Body><ns2:getInventoryDaysInTransitResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/"><return><errorOccured>false</errorOccured><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>500</quantity><size>2XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>500</quantity><size>2XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>500</quantity><size>2XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>160</quantity><size>3XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>221</quantity><size>3XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>298</quantity><size>3XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>93</quantity><size>4XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>102</quantity><size>4XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>51</quantity><size>4XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>0</quantity><size>5XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>4</quantity><size>5XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>109</quantity><size>5XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>20</quantity><size>6XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>46</quantity><size>6XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>26</quantity><size>6XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>500</quantity><size>L</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>500</quantity><size>L</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>500</quantity><size>L</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>500</quantity><size>M</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>500</quantity><size>M</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>500</quantity><size>M</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>500</quantity><size>S</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>500</quantity><size>S</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>500</quantity><size>S</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>500</quantity><size>XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>500</quantity><size>XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>500</quantity><size>XL</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>4</daysInTransit><quantity>378</quantity><size>XS</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>3</daysInTransit><quantity>206</quantity><size>XS</size><style>K500</style></listResponse><listResponse><color>Maroon</color><daysInTransit>1</daysInTransit><quantity>53</quantity><size>XS</size><style>K500</style></listResponse><message>Inventory returned successfully.</message></return></ns2:getInventoryDaysInTransitResponse></S:Body></S:Envelope>

Open in new window

0
 
Geert BormansCommented:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:map="#internal"
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table>
                    <tr>
                        <th></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <th><xsl:value-of select="."/></th>
                        </xsl:for-each>
                     </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'dozenPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'piecePrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>2XL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
</xsl:stylesheet>

Open in new window

0
 
Geert BormansCommented:
That would be the XSLT, equivalent to the one before, but now working on your compound document (the XML you sentw as exactly what I expected (and needed))
0
 
P-DaddyAuthor Commented:
Thanks so much!

The only modification I can see requested is alternating row colors with XSLT. Is that easy? I'm going to see if I can figure out now.
0
 
P-DaddyAuthor Commented:
Able to alternate with CSS nth-child.
0
 
Geert BormansCommented:
Hi, I am not sure what the browser support is for nth-child,
you can add classes to the rows

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:map="#internal"
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table>
                    <tr>
                        <th></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <th><xsl:value-of select="."/></th>
                        </xsl:for-each>
                     </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'dozenPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'piecePrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"></xsl:param>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"></xsl:param>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td>
                    <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>2XL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
</xsl:stylesheet>

Open in new window

0
 
P-DaddyAuthor Commented:
Hi Geert,

During testing, three additional requests were made:

1) Hide column if there’s no data for the column in any of the rows (hide 5XL if no price or qty exists, etc)

2) Create a row at the very bottom that is a total of all the quantities for that column (total qty of all S, total qty of all M, etc)

3) Is there a way to show the name of the day and the date for that transit time? If it falls on a Saturday or Sunday, then add 2 days.  

Can you help?

Your code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:map="#internal"
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
       
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <th align="center" width="50" style="border-bottom: 2px solid #93b744;"><xsl:value-of select="."/></th>
                        </xsl:for-each>
                     </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                    </xsl:call-template>
                 
                   
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                    </xsl:call-template>
                </table>
         
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th align="right">Price</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td align="right">
                    $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"></xsl:param>
        <tr>
            <th align="right">Stock available to reach you in <xsl:value-of select="$type"/> days</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <td align="right">
                     <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"/> 
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
</xsl:stylesheet>

Open in new window

add.png
0
 
Geert BormansCommented:
I have implemented 1 and 2
(there is a class="total" for the total row)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:map="#internal"
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table>
                    <tr>
                        <th></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th><xsl:value-of select="."/></th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'dozenPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'piecePrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                         <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"></xsl:param>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"></xsl:param>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th><xsl:value-of select="$type"/></th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"></xsl:param>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th>Total</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>2XL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
</xsl:stylesheet>

Open in new window

0
 
Geert BormansCommented:
Regarding 3)
I am not sure about the logic you want
I think what I understand is this
now first column says 1, 2, 3, 4
today is Wednesday
1 = Thursday
2 = Friday
3 = Monday
4 = Tuesday
So it is just a matter of making the title column more smart?
I need some extension functions for that (it's almost becoming a project)
0
 
P-DaddyAuthor Commented:
Geert do you have PayPal? What's the name on account? I really appreciate the help.

These are things I can do easily with ASP but have no experience with XSLT. I've learned so much!
0
 
Geert BormansCommented:
Working for msxml only (since it requires extensions)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" version="1.0">

    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>

    <xsl:template match="/">
        <html>
            <body>
                <table>
                    <tr>
                        <th/>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if
                                test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th>
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'dozenPrice'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'piecePrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                        <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th>
                <xsl:value-of select="$type"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of
                            select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th>
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of
                            select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th>Total</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td>
                        <xsl:value-of
                            select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>2XL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>

    <msxsl:script language="JScript" implements-prefix="date">
        <![CDATA[
       function  calculateDay(i){
            var d = new Date() ;
            var wd = d.getDay() + i;
            wd = wd % 7;
            if ( wd == 6 || wd == 0) {wd = wd + 2};
            wd = wd % 7;
            switch(wd) {
                case 1: return("Monday");
                case 2: return("Tuesday");
                case 3: return("Wednesday");
                case 4: return("Thursday");
                case 5: return("Friday");
                default: return (wd);
                }
       }
        ]]>
    </msxsl:script>

</xsl:stylesheet>

Open in new window

0
 
Geert BormansCommented:
Note that I posted the solution for 3) before I saw your paypal message.
Just to make clear I did not provide a solution to that for the money :-)

I assume you use ASP around the XSLT still so msxml is a safe choice
you might have to enable the script functionality in your XSLT process
(similar as to what you did for the document() function)
0
 
P-DaddyAuthor Commented:
Their SOAP services still down. Haven't been able to do anything. :(
0
 
P-DaddyAuthor Commented:
The solution to show the days works perfect except I added a 5th day and that threw things off. 5 is max and not 4. Is it possible to show the month and day numerical value beside the name of the day (e.g. Thursday 4/2). I uploaded graphic with current output.

Is it possible to hide rows if there isn't any data?

The first row says 1 days. Is it possible to have the first one say "day"?

Here's the latest code with the 5th day added and some styles.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" 
    version="1.0">

    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>

    <xsl:template match="/">
        <html>
            <body>
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th align="center" width="50" style="border-bottom: 2px solid #93b744;">
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>                    
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                     <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'5'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                        <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                Price
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td  align="right">
                        $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">Stock available to reach you in <xsl:value-of select="$type"/> days
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">Total</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>

    <msxsl:script language="JScript" implements-prefix="date">
        <![CDATA[
       function  calculateDay(i){
            var d = new Date() ;
            var wd = d.getDay() + i;
            wd = wd % 7;
            if ( wd == 6 || wd == 0) {wd = wd + 2};
            wd = wd % 7;
            switch(wd) {
                case 1: return("Monday");
                case 2: return("Tuesday");
                case 3: return("Wednesday");
                case 4: return("Thursday");
                case 5: return("Friday");
                default: return (wd);
                }
       }
        ]]>
    </msxsl:script>

</xsl:stylesheet>

Open in new window

testing.jpg
0
 
Geert BormansCommented:
I will look into that tomorrow or so.
Some things are easy, others can throw off the striping so I need to give it some thoughts

Please note that you are making it a real project,
Experts Exchange is for helping people to help themselves.
Experts Exchange is not meant for throwing in requirements one after the other and hoping that at the end you get the perfect code.
I just want to manage your expectations, I hope you understand.
0
 
P-DaddyAuthor Commented:
Thanks very much for your help. I understand. I don't post here often. Most things I figure out in my own. However, I'm clueless here and you're so close.
0
 
P-DaddyAuthor Commented:
Hiding the rows with no days is most important to me.
0
 
P-DaddyAuthor Commented:
So I figured out how to make "days" into "day" using when/otherwise when it's 1 day! Bam!
0
 
P-DaddyAuthor Commented:
<xsl:choose>
        <xsl:when test="$type = '1'">
            <th align="right">Stock available to reach you in <xsl:value-of select="$type"/> day
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>  
         </xsl:when>
         <xsl:otherwise>
             <th align="right">Stock available to reach you in <xsl:value-of select="$type"/> days
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
         </xsl:otherwise>
         </xsl:choose>
0
 
Geert BormansCommented:
Do you have an XML example of the the set having up to 5 days?
0
 
Geert BormansCommented:
smarter would be to have simple xsl:if on the "s"

            <th align="right">
                <xsl:text>Stock available to reach you in </xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text> day</xsl:text>
                <xsl:if test="$type > 1">
                    <xsl:text>s</xsl:text>
                </xsl:if>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>

Open in new window

0
 
Geert BormansCommented:
About the dates being off... I tend to not agree.
You asked me to add two days if delivery was on Saturday or Sunday

1 day = Thursday
2 days = Friday
3 days = Saturday + 2 = Monday
4 days = Sunday + 2 = Tuesday
5 days = Monday

I think the jpeg is correct, at least it is in line with what I implemented

Another question, I suppose you want to maintain the striping if I drop a empty line?
0
 
P-DaddyAuthor Commented:
Here's an example with 5 days and no data for 4th.

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getInventoryDaysInTransitResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
         <return>
            <errorOccured>false</errorOccured>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>2XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>2XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>439</quantity>
               <size>2XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>259</quantity>
               <size>2XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>59</quantity>
               <size>3XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>320</quantity>
               <size>3XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>3XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>149</quantity>
               <size>3XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>35</quantity>
               <size>4XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>468</quantity>
               <size>4XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>4XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>34</quantity>
               <size>4XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>L</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>L</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>500</quantity>
               <size>M</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>M</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>M</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>M</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>349</quantity>
               <size>S</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>S</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>S</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>316</quantity>
               <size>S</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>3</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>1</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>2</daysInTransit>
               <quantity>0</quantity>
               <size>XL</size>
               <style>KP155</style>
            </listResponse>
            <listResponse>
               <color>Charcoal</color>
               <daysInTransit>5</daysInTransit>
               <quantity>500</quantity>
               <size>XL</size>
               <style>KP155</style>
            </listResponse>
            <message>Inventory returned successfully.</message>
         </return>
      </ns2:getInventoryDaysInTransitResponse>
   </S:Body>
</S:Envelope>

Open in new window



You wrote:

About the dates being off... I tend to not agree.
You asked me to add two days if delivery was on Saturday or Sunday

1 day = Thursday
2 days = Friday
3 days = Saturday + 2 = Monday
4 days = Sunday + 2 = Tuesday
5 days = Monday


In my mind, that 5th day would have been Wednesday.

Another question, I suppose you want to maintain the striping if I drop a empty line?

I don't understand.
0
 
P-DaddyAuthor Commented:
smarter would be to have simple xsl:if on the "s"

That is smarter. I'm the noob and just happy mine didn't error out!
0
 
Geert BormansCommented:
That is a different requirement then

your original question: "If it falls on a Saturday or Sunday, then add 2 days."

you actually mean: if there is a Saturday or Sunday in between, add two days

correct?
0
 
P-DaddyAuthor Commented:
Deliveries don't happen on Saturday or Sunday so those days should not be considered in the transit time.
0
 
P-DaddyAuthor Commented:
That's correct.
0
 
Geert BormansCommented:
This will get the elapse date right, rest will follow

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" 
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th align="center" width="50" style="border-bottom: 2px solid #93b744;">
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>                    
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'2'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'3'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'4'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'5'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                        <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                Price
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td  align="right">
                        $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                <xsl:text>Stock available to reach you in </xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text> day</xsl:text>
                <xsl:if test="$type > 1">
                    <xsl:text>s</xsl:text>
                </xsl:if>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">Total</th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
    <msxsl:script language="JScript" implements-prefix="date">
        <![CDATA[
       function  calculateDay(i){
            var d = new Date() ;
            var wd = d.getDay();
            wd = addDay(wd, i);
            switch(wd) {
                case 1: return("Monday");
                case 2: return("Tuesday");
                case 3: return("Wednesday");
                case 4: return("Thursday");
                case 5: return("Friday");
                default: return (wd);
                }
       }

        function  addDay(d, i){
            var wd = d + 1;
            wd = wd % 7;
            if ( wd == 6 || wd == 0) {wd = wd + 2};
            wd = wd % 7;
            if (i == 1 || i == 0) {return wd};
            if (i > 1) {return addDay(wd, i - 1)};
           }
        ]]>
    </msxsl:script>
    
</xsl:stylesheet>

Open in new window

0
 
P-DaddyAuthor Commented:
Worked!
0
 
Geert BormansCommented:
Here is code that
- calculates the dates in transit right and gives the correct arrival weekday
- filters out the empty rows [new]
- maintains the odd-even class for striping by recursion [new]

What I have not done so far is adding the dates to the transit.
The reason for that is that the JavaScript object has flaws when dealing with date addition,
so I would have to write a lot of JAvaScript to make that right, or move to C# for that
Will look into that later if crucial, but have customers waiting
0
 
P-DaddyAuthor Commented:
I don't see the code in your last post.
0
 
Geert BormansCommented:
good point :-)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" 
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th align="center" width="50" style="border-bottom: 2px solid #93b744;">
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>                    
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                Price
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td  align="right">
                        $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="odd-even" select="'odd'"/>
        <xsl:variable name="content-test" select="$t-doc//return/listResponse[daysInTransit = $type]/quantity and not(sum($t-doc//return/listResponse[daysInTransit = $type]/quantity) = 0)"/>
        <xsl:variable name="next-odd-even">
            <xsl:choose>
                <xsl:when test="$content-test and $odd-even = 'odd'">
                    <xsl:value-of select="'even'"/>
                </xsl:when>
                <xsl:when test="$content-test and $odd-even = 'even'">
                    <xsl:value-of select="'odd'"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$odd-even"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:if test="$content-test">
            <tr class="{$odd-even}">
            <th align="right">
                <xsl:text>Stock available to reach you in </xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text> day</xsl:text>
                <xsl:if test="$type > 1">
                    <xsl:text>s</xsl:text>
                </xsl:if>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
        </xsl:if>
        <xsl:if test="$type &lt; 5">
            <xsl:call-template name="get-transit-row">
                <xsl:with-param name="type" select="$type + 1"/>
                <xsl:with-param name="odd-even" select="$next-odd-even"></xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
             <tr class="{$class}">
                <th align="right">Total</th>
                <xsl:for-each select="document('')//map:sizes/size">
                    <xsl:variable name="this-size" select="."/>
                    <xsl:if
                        test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                        <td align="right">
                            <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                        </td>
                    </xsl:if>
                </xsl:for-each>
            </tr>
     </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
    <msxsl:script language="JScript" implements-prefix="date">
        <![CDATA[
       function  calculateDay(i){
            var d = new Date() ;
            var wd = d.getDay();
            wd = addDay(wd, i);
            switch(wd) {
                case 1: return("Monday");
                case 2: return("Tuesday");
                case 3: return("Wednesday");
                case 4: return("Thursday");
                case 5: return("Friday");
                default: return (wd);
                }
       }

        function  addDay(d, i){
            var wd = d + 1;
            wd = wd % 7;
            if ( wd == 6 || wd == 0) {wd = wd + 2};
            wd = wd % 7;
            if (i == 1 || i == 0) {return wd};
            if (i > 1) {return addDay(wd, i - 1)};
           }
        ]]>
    </msxsl:script>
    
</xsl:stylesheet>

Open in new window

0
 
P-DaddyAuthor Commented:
I see you filter out the rows with no data but also lost the Total row that was the last row. Is there a way to keep that Total row?
0
 
Geert BormansCommented:
I might have deleted the call template for the total row
just bring that back in
0
 
Geert BormansCommented:
indeed

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" 
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th align="center" width="50" style="border-bottom: 2px solid #93b744;">
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>                    
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                        <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                Price
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td  align="right">
                        $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="odd-even" select="'odd'"/>
        <xsl:variable name="content-test" select="$t-doc//return/listResponse[daysInTransit = $type]/quantity and not(sum($t-doc//return/listResponse[daysInTransit = $type]/quantity) = 0)"/>
        <xsl:variable name="next-odd-even">
            <xsl:choose>
                <xsl:when test="$content-test and $odd-even = 'odd'">
                    <xsl:value-of select="'even'"/>
                </xsl:when>
                <xsl:when test="$content-test and $odd-even = 'even'">
                    <xsl:value-of select="'odd'"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$odd-even"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:if test="$content-test">
            <tr class="{$odd-even}">
            <th align="right">
                <xsl:text>Stock available to reach you in </xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text> day</xsl:text>
                <xsl:if test="$type > 1">
                    <xsl:text>s</xsl:text>
                </xsl:if>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:calculateDay(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
        </xsl:if>
        <xsl:if test="$type &lt; 5">
            <xsl:call-template name="get-transit-row">
                <xsl:with-param name="type" select="$type + 1"/>
                <xsl:with-param name="odd-even" select="$next-odd-even"></xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
             <tr class="{$class}">
                <th align="right">Total</th>
                <xsl:for-each select="document('')//map:sizes/size">
                    <xsl:variable name="this-size" select="."/>
                    <xsl:if
                        test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                        <td align="right">
                            <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                        </td>
                    </xsl:if>
                </xsl:for-each>
            </tr>
     </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
    <msxsl:script language="JScript" implements-prefix="date">
        <![CDATA[
       function  calculateDay(i){
            var d = new Date() ;
            var wd = d.getDay();
            wd = addDay(wd, i);
            switch(wd) {
                case 1: return("Monday");
                case 2: return("Tuesday");
                case 3: return("Wednesday");
                case 4: return("Thursday");
                case 5: return("Friday");
                default: return (wd);
                }
       }

        function  addDay(d, i){
            var wd = d + 1;
            wd = wd % 7;
            if ( wd == 6 || wd == 0) {wd = wd + 2};
            wd = wd % 7;
            if (i == 1 || i == 0) {return wd};
            if (i > 1) {return addDay(wd, i - 1)};
           }
        ]]>
    </msxsl:script>
    
</xsl:stylesheet>

Open in new window

0
 
P-DaddyAuthor Commented:
You're right. I added it back and it's working. THANK YOU!
0
 
Geert BormansCommented:
You will love this ...

If you happen to use .net XSLT instead of msxml4 xslt, you would be able to use C# as extension functions instead of JavaScript.
The dateTime methods for C# are much more reliable, so I can do this

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sanmar="http://impl.webservice.integration.sanmar.com/"
    xmlns:date="urn:com:c-moria:msxsl:ext:date" 
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:map="#internal" 
    version="1.0">
    
    <xsl:variable name="doc" select="//sanmar:getPricingResponse"/>
    <xsl:variable name="t-doc" select="//sanmar:getInventoryDaysInTransitResponse"/>
    
    <xsl:template match="/">
        <html>
            <body>
                <table border="0" cellspacing="3" cellpadding="3" class="myTable">
                    <tr bgcolor="#dedfd7">
                        <th width="250" style="border-bottom: 2px solid #93b744;"></th>
                        <xsl:for-each select="document('')//map:sizes/size">
                            <xsl:variable name="this-size" select="."/>
                            <xsl:if test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                                <th align="center" width="50" style="border-bottom: 2px solid #93b744;">
                                    <xsl:value-of select="."/>
                                </th>
                            </xsl:if>
                        </xsl:for-each>
                    </tr>
                    <xsl:call-template name="get-price-row">
                        <xsl:with-param name="type" select="'myPrice'"/>
                        <xsl:with-param name="class" select="'even'"/>
                    </xsl:call-template>                    
                    <xsl:call-template name="get-transit-row">
                        <xsl:with-param name="type" select="'1'"/>
                    </xsl:call-template>
                    <xsl:call-template name="get-total-transit-row">
                        <xsl:with-param name="class" select="'total'"/>
                    </xsl:call-template>
                </table>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="get-price-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
        <tr class="{$class}">
            <th align="right">
                Price
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td  align="right">
                        $<xsl:value-of select="$doc//return/listResponse[size = $this-size]/*[local-name() = $type]"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
    </xsl:template>
    
    <xsl:template name="get-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="odd-even" select="'odd'"/>
        <xsl:variable name="content-test" select="$t-doc//return/listResponse[daysInTransit = $type]/quantity and not(sum($t-doc//return/listResponse[daysInTransit = $type]/quantity) = 0)"/>
        <xsl:variable name="next-odd-even">
            <xsl:choose>
                <xsl:when test="$content-test and $odd-even = 'odd'">
                    <xsl:value-of select="'even'"/>
                </xsl:when>
                <xsl:when test="$content-test and $odd-even = 'even'">
                    <xsl:value-of select="'odd'"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$odd-even"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:if test="$content-test">
            <tr class="{$odd-even}">
            <th align="right">
                <xsl:text>Stock available to reach you in </xsl:text>
                <xsl:value-of select="$type"/>
                <xsl:text> day</xsl:text>
                <xsl:if test="$type > 1">
                    <xsl:text>s</xsl:text>
                </xsl:if>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:calculateDayString(number($type))"/>
            </th>
            <xsl:for-each select="document('')//map:sizes/size">
                <xsl:variable name="this-size" select="."/>
                <xsl:if
                    test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                    <td align="right">
                        <xsl:value-of select="$t-doc//return/listResponse[size = $this-size][daysInTransit = $type]/quantity"
                        />
                    </td>
                </xsl:if>
            </xsl:for-each>
        </tr>
        </xsl:if>
        <xsl:if test="$type &lt; 5">
            <xsl:call-template name="get-transit-row">
                <xsl:with-param name="type" select="$type + 1"/>
                <xsl:with-param name="odd-even" select="$next-odd-even"></xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
    <xsl:template name="get-total-transit-row">
        <xsl:param name="type"/>
        <xsl:param name="class" select="'odd'"/>
             <tr class="{$class}">
                <th align="right">Total:</th>
                <xsl:for-each select="document('')//map:sizes/size">
                    <xsl:variable name="this-size" select="."/>
                    <xsl:if
                        test="$doc//listResponse[size = $this-size] | $t-doc//listResponse[size = $this-size]">
                        <td align="right">
                            <xsl:value-of select="sum($t-doc//return/listResponse[size = $this-size]/quantity)"/>
                        </td>
                    </xsl:if>
                </xsl:for-each>
            </tr>
     </xsl:template>
    
    <map:sizes>
        <size>XS</size>
        <size>S</size>
        <size>M</size>
        <size>L</size>
        <size>XL</size>
        <size>XXL</size>
        <size>3XL</size>
        <size>4XL</size>
        <size>5XL</size>
        <size>6XL</size>
    </map:sizes>
    
    <msxsl:script language="C#" implements-prefix="date">
        <![CDATA[
        public string calculateDayString(Double i)
            {
            DateTime today = DateTime.Today;
            DateTime nextdate  = addDay(today, i);
            string nxtdtstr = " ("+ nextdate.ToString("dd/MM") + ")";
            switch(nextdate.DayOfWeek) {
                case DayOfWeek.Monday: return("Monday" + nxtdtstr ) ; break;
                case DayOfWeek.Tuesday: return("Tuesday" + nxtdtstr ); break;
                case DayOfWeek.Wednesday: return("Wednesday" + nxtdtstr ); break;
                case DayOfWeek.Thursday: return("Thursday" + nxtdtstr ); break;
                case DayOfWeek.Friday: return("Friday" + nxtdtstr ); break;
                default: return(nxtdtstr ); break;
                }
            }

        public DateTime addDay(DateTime d, Double i){
            d = d.AddDays(1);
            if (d.DayOfWeek == DayOfWeek.Saturday || d.DayOfWeek == DayOfWeek.Sunday)
                {
                    d = d.AddDays(2);
                }
            if (i == 1 || i == 0) {return d;}
            else {return addDay(d, i - 1);}
           }
        ]]>
    </msxsl:script>
    
</xsl:stylesheet>

Open in new window

0
 
P-DaddyAuthor Commented:
Got this error which I'm looking at now.

msxml3.dll error '800401f3'

Invalid class string

/sanmar/sanmarRequest.asp, line 333

Open in new window

0
 
P-DaddyAuthor Commented:
I read what you wrote before the code and my error makes sense now. :)

Working on using .net XSLT.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 29
  • 28
Tackle projects and never again get stuck behind a technical roadblock.
Join Now