P-Daddy
asked on
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?
How would I do this using this example for the SKU K500?
Pricing XML:
Days in transit XML:
Using XSLT, is it possible to combine the two XML files into a table like this?
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>
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>
Do you realize that you posted the same XML twice?
ASKER
I sure did!
Here's the transit XML:
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>
<?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>
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
- 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
ASKER
Thank you Geert!
Before I would load the (transit) XML and display the formatted table using:
How would I go about this using your code where you're pointing to transit.xml?
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
How would I go about this using your code where you're pointing to transit.xml?
ASKER
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.
So would this line need to change in the XSL file?
I still need to find a way to load the transit XML from the web service and not path in XSL.
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
So would this line need to change in the XSL file?
<xsl:variable name="doc" select="/"/>
I still need to find a way to load the transit XML from the web service and not path in XSL.
Hi, just returned home but off to bed now, wil look into this in the morning
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($transitd oc)"/>
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("MSXML 2.FreeThre adedDOMDoc ument")
to become
Set objXSLT = Server.CreateObject("MSXML 2.FreeThre adedDOMDoc ument")
objXSLT.setProperty("Allow DocumentFu nction", true)
after that, it should work
replace this
<xsl:variable name="t-doc" select="document('transit.
with
<xsl:param name="transitdoc" select="'transit.xml'"/>
<xsl:variable name="t-doc" select="document($transitd
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("MSXML
to become
Set objXSLT = Server.CreateObject("MSXML
objXSLT.setProperty("Allow
after that, it should work
ASKER
Today, transit.xml does not exist as a file. I call a web service and load the transit xml using
Set objXML = Server.CreateObject("MSXML 2.DOMDocum ent")
objXML.async = False
objXML.load(oXmlHTTP.respo nseXML)
Is there a way to do this without having to save a file called transit.xml on the server?
Hope that make sense.
Set objXML = Server.CreateObject("MSXML
objXML.async = False
objXML.load(oXmlHTTP.respo
Is there a way to do this without having to save a file called transit.xml on the server?
Hope that make sense.
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
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
ASKER
Yeah both are SOAP requests. I will post code tomorrow when back in the office.
Thanks for help.
Thanks for help.
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?
Recommended approach is likely to combine the two SOAP responses into one big XML and pass that to the XSLT.
Can you do that?
ASKER
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:
Request to get transit info:
How do I combine the two and use your XSLT template to display?
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)
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)
How do I combine the two and use your XSLT template to display?
// pricing
Set objXMLp = Server.CreateObject("MSXML 2.DOMDocum ent")
objXMLp.async = False
objXMLp.load(oXmlPricingHT TP.respons eXML)
//transit
Set objXMLt = Server.CreateObject("MSXML 2.DOMDocum ent")
objXMLt.async = False
objXMLt.load(oXmlTransitHT TP.respons eXML)
set tnodes = objXMLt.selectNodes("/*/*" )
for each node in tnodes
objXMLp.documentElement.ap pendChild 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
Set objXMLp = Server.CreateObject("MSXML
objXMLp.async = False
objXMLp.load(oXmlPricingHT
//transit
Set objXMLt = Server.CreateObject("MSXML
objXMLt.async = False
objXMLt.load(oXmlTransitHT
set tnodes = objXMLt.selectNodes("/*/*"
for each node in tnodes
objXMLp.documentElement.ap
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
ASKER
Here's my code and the error below.
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/sanmar/sanmarRequest.asp, line 237
line 237 is
'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
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/sanmar/sanmarRequest.asp,
line 237 is
objXMLp.documentElement.appendChild node
ASKER
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")
did you load the objXMLp already at that point?
seems to be empty
seems to be empty
mmh, I am not sure about the save action, am not that familiar with ASP
ASKER
I was able to fix the error and output objXMLp.
Here's the XML of 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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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))
ASKER
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.
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.
ASKER
Able to alternate with CSS nth-child.
Hi, I am not sure what the browser support is for nth-child,
you can add classes to the rows
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>
ASKER
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:
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>
add.png
I have implemented 1 and 2
(there is a class="total" for the total row)
(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>
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)
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)
ASKER
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!
These are things I can do easily with ASP but have no experience with XSLT. I've learned so much!
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>
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)
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)
ASKER
Their SOAP services still down. Haven't been able to do anything. :(
ASKER
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.
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>
testing.jpg
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.
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.
ASKER
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.
ASKER
Hiding the rows with no days is most important to me.
ASKER
So I figured out how to make "days" into "day" using when/otherwise when it's 1 day! Bam!
ASKER
<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($ty pe))"/>
</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($ty pe))"/>
</th>
</xsl:otherwise>
</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(
</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(
</th>
</xsl:otherwise>
</xsl:choose>
Do you have an XML example of the the set having up to 5 days?
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>
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?
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?
ASKER
Here's an example with 5 days and no data for 4th.
You wrote:
In my mind, that 5th day would have been Wednesday.
I don't understand.
<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>
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.
ASKER
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!
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?
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?
ASKER
Deliveries don't happen on Saturday or Sunday so those days should not be considered in the transit time.
ASKER
That's correct.
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>
ASKER
Worked!
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
- 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
ASKER
I don't see the code in your last post.
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 < 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>
ASKER
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?
I might have deleted the call template for the total row
just bring that back in
just bring that back in
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 < 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>
ASKER
You're right. I added it back and it's working. THANK YOU!
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
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 < 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>
ASKER
Got this error which I'm looking at now.
msxml3.dll error '800401f3'
Invalid class string
/sanmar/sanmarRequest.asp, line 333
ASKER
I read what you wrote before the code and my error makes sense now. :)
Working on using .net XSLT.
Working on using .net XSLT.