CodeToad Forums » ASP » How to reorder or Re arrange the node in XSL Using ASP and VBScript
|
|
|
How to display the following.
<PRODUCT productid="12678" catalogname="Movie">
<PRODUCTVARIANT hideremove="0" DisplayOrder="2" itemindex="0" sku="SKU_ET_33705_1" title="BB"/>
<PRODUCTVARIANT hideremove="0" DisplayOrder="3" itemindex="1" sku="SKU_ET_33705_2" title="CC"/>
<PRODUCTVARIANT hideremove="0" DisplayOrder="1" itemindex="2" sku="SKU_ET_33705_3" title="AA"/>
</PRODUCT>
The above XSL node 'PRODUCTVARIANT' should sort using VBscript and ASP3.0. The node should sorted using 'DisplayOrder' attribute value.
the DisplayOrder value may vary from 1 to n. Some more attribute are there in that node 'PRODUCTVARIANT' . The key attribute used is 'DisplayOrder'.Can Any one try this. Some code i tried is attached in this thread
My Code::
set oProduct = oEventCatalog.GetProduct(productid)
if ( not oProduct is nothing ) then
Set oNode = xoService.CreateElement("PRODUCT")
oNode.setAttribute "productid" , oProduct.productid
oNode.setattribute "catalogname" , oProduct.CatalogName
Set oProductVariants = oProduct.Variants
'i=0
while oProductVariants.eof = false
if oProductVariants("IsDisabled") = 1 then
'Do nothing
else
Set oVariantNode = xoService.CreateElement("PRODUCTVARIANT")
oVariantNode.setAttribute "DisplayOrder", oProductVariants.fields("DisplayOrder")
'oVariantNode.setAttribute "itemindex", i
'i = i + 1
'dim L(0)
V = XoService.childNodes.length
redim L(V)
for i = 0 to V - 1
D = oVariantNode.getAttribute("DisplayOrder")
'if oVariantNode.getAttribute("DisplayOrder") = L(i)
L(i) = D
if L(i) > L(i + 1) Then
tempvar = L(i)
L(i) = L(i + 1)
L(i + 1) = tempvar
end if
Next
if ( not IsNull(oProductVariants.fields("qtyAvailable")) ) then
oVariantNode.setAttribute "IsDisabled", oProductVariants.fields("IsDisabled")
else
oVariantNode.setAttribute "IsDisabled", "0"
end if
oVariantNode.setAttribute "sku", oProductVariants.fields("sku")
oVariantNode.setAttribute "title", oProductVariants.fields("title")
'
if ( not IsNull(oProductVariants.fields("qtyAvailable")) ) then
oVariantNode.SetAttribute "qtyavailable", oProductVariants.fields("qtyavailable")
else
oVariantNode.SetAttribute "qtyavailable", "9999"
end if
if ( not IsNull(oProductVariants.fields("maxperorder")) ) then
oVariantNode.setAttribute "maxperorder", oProductVariants.fields("maxperorder")
else
oVariantNode.setAttribute "maxperorder", "9999"
end if
if ( not IsNull(oProductVariants.fields("minperorder")) ) then
oVariantNode.setAttribute "minperorder", oProductVariants.fields("minperorder")
else
oVariantNode.setAttribute "minperorder", "9999"
end if
oVariantNode.setAttribute "cy_list_price", oProductVariants.fields("cy_list_price")
oVariantNode.setAttribute "productname", oProductVariants.fields("productname")
oNode.AppendChild(oVariantNode)
'XoService.insertBefore XoService.createElement("PRODUCTVARIANT"), XoService.childNodes(i)
end if
ProductVariants.MoveNext
wend
oRootNode.AppendChild(oNode)
end if
Set oProductVariants = nothing
|
|
|
|
|
|
|
|