Jagar
asked on
SelectNodes not work??
I have the following statement in an ASP page
Style.XMLDocument.selectNo des("//xsl :for-each/ @select")( 1).value = "./*[position() < " & iRecordsPerPage + 1 & " and position() > 0]"
What is happening when this code is being executed is that Style.XMLDocument.selectNo des("//xsl :for-each/ @select")( 1).value is evaluating to nothing.
Here is the XSL that is being referenced. You will notice about half way down it clearly says <xsl:for-each select="...">, so I don't know why the SelectNodes above is not working.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-m icrosoft-c om:xslt" xmlns:user="urn:user-names pace-here" version="1.0">
<msxsl:script language="VBScript" implements-prefix="user">
<![CDATA[
function getName(node)
getName = node.item(0).NodeName
end function
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:apply-templates select="/*" />
</xsl:template>
<xsl:template match="/*">
<table width="100%">
<tr>
<td align="left" valign="bottom"><b>Page <span id="CurrentPage"></span>&# 160; of  <span id="PageCount"></span>. Total PODs: <span id="RecordCount"></span>&# 160;</b></ td>
<td align="right"><b>PODs Per Page: <input onblur="setRecordsPerPage( )" id="RecordsPerPage" type="text" size="2"></input></b></td>
<td align="right" valign="bottom">
<span id="Paging" style="Display:">
<input type="button" OnClick="FirstPage()"><xsl :attribute name="value"><![CDATA[|<]] ></xsl:att ribute></i nput>
<input type="button" OnClick="PreviousPage(1)"> <xsl:attri bute name="value"><![CDATA[<]]> </xsl:attr ibute></in put>
<input type="button" OnClick="NextPage(1)" value=">"></input>
<input type="button" OnClick="LastPage()" value=">|"></input>
</span>
</td>
</tr>
</table>
<table width="100%" border="1" topmargin="0" leftmargin="0" cellpadding="0" cellspacing="0">
<tr style="cursor: hand">
<td bgcolor="#CCFFFF" onclick="Sort('DATEREQUEST ED')"><b>< u><nobr>Re quested On</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('PERSONREQUE STED')"><b ><u><nobr> Requested By</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('PLANTID')"> <b><u><nob r>Plant</n obr></u></ b></td>
<td bgcolor="#CCFFFF" onclick="Sort('SHIPDATE')" ><b><u><no br>Shipped On</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('DELIVERYDAT E')"><b><u ><nobr>Del ivered On</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('ORDERNUMBER ')"><b><u> <nobr>Orde r Number</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('SLIMVMT')"> <b><u><nob r>SLI MVMT #</nobr></u></b></td>
<td bgcolor="#CCFFFF" onclick="Sort('CUSTNAME')" ><b><u><no br>Custome r</nobr></ u></b></td >
<td bgcolor="#CCFFFF" onclick="Sort('CITY')"><b> <u><nobr>C ity</nobr> </u></b></ td>
<td bgcolor="#CCFFFF" onclick="Sort('STATE')"><b ><u><nobr> State</nob r></u></b> </td>
<td bgcolor="#CCFFCC" onclick="Sort('PERSONOBTAI NING')"><b ><u><nobr> Obtained By</nobr></u></b></td>
<td bgcolor="#CCFFCC" onclick="Sort('SCACID')">< b><u><nobr >SCAC</nob r></u></b> </td>
<td bgcolor="#CCFFCC" onclick="Sort('FIRSTCARRIE R')"><b><u ><nobr>Fir st Carrier</nobr></u></b></td >
<td bgcolor="#CCFFCC" onclick="Sort('SECONDCARRI ER')"><b>< u><nobr>Se cond Carrier</nobr></u></b></td >
<td bgcolor="#CCFFCC" onclick="Sort('THIRDCARRIE R')"><b><u ><nobr>Thi rd Carrier</nobr></u></b></td >
<td bgcolor="#CCFFCC" onclick="Sort('PODRECEIVED ')"><b><u> <nobr>POD Received</nobr></u></b></t d>
<td bgcolor="#CCFFCC" onclick="Sort('SLISHIPTOOS CDATE')">< b><u><nobr >SLI Ship To OSC</nobr></u></b></td>
<td onclick="Sort('OSCRECEIVED DATE')"><b ><u><nobr> OSC Received</nobr></u></b></t d>
<td onclick="Sort('COMMENTS')" ><b><u><no br>Comment s</nobr></ u></b></td >
</tr>
<xsl:for-each select="./*[position() < 6 and position() > 0]">
<xsl:sort select="./*[1]" order="ascending" />
<tr>
<td bgcolor="CCFFFF"> <xs l:value-of select="DATEREQUESTED" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="PERSONREQUESTED" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="PLANTID" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="SHIPDATE" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="DELIVERYDATE" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="ORDERNUMBER" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="SLIMVMT" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="CUSTNAME" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="CITY" /></td>
<td bgcolor="CCFFFF"> <xs l:value-of select="STATE" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="PERSONOBTAINING" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="SCACID" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="FIRSTCARRIER" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="SECONDCARRIER" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="THIRDCARRIER" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="PODRECEIVED" /></td>
<td bgcolor="CCFFCC"> <xs l:value-of select="SLISHIPTOOSCDATE" /></td>
<td> <xsl:value-of select="OSCRECEIVEDDATE" /></td>
<td> <xsl:value-of select="COMMENTS" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Style.XMLDocument.selectNo
What is happening when this code is being executed is that Style.XMLDocument.selectNo
Here is the XSL that is being referenced. You will notice about half way down it clearly says <xsl:for-each select="...">, so I don't know why the SelectNodes above is not working.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-m
<msxsl:script language="VBScript" implements-prefix="user">
<![CDATA[
function getName(node)
getName = node.item(0).NodeName
end function
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:apply-templates select="/*" />
</xsl:template>
<xsl:template match="/*">
<table width="100%">
<tr>
<td align="left" valign="bottom"><b>Page <span id="CurrentPage"></span>&#
<td align="right"><b>PODs Per Page: <input onblur="setRecordsPerPage(
<td align="right" valign="bottom">
<span id="Paging" style="Display:">
<input type="button" OnClick="FirstPage()"><xsl
<input type="button" OnClick="PreviousPage(1)">
<input type="button" OnClick="NextPage(1)" value=">"></input>
<input type="button" OnClick="LastPage()" value=">|"></input>
</span>
</td>
</tr>
</table>
<table width="100%" border="1" topmargin="0" leftmargin="0" cellpadding="0" cellspacing="0">
<tr style="cursor: hand">
<td bgcolor="#CCFFFF" onclick="Sort('DATEREQUEST
<td bgcolor="#CCFFFF" onclick="Sort('PERSONREQUE
<td bgcolor="#CCFFFF" onclick="Sort('PLANTID')">
<td bgcolor="#CCFFFF" onclick="Sort('SHIPDATE')"
<td bgcolor="#CCFFFF" onclick="Sort('DELIVERYDAT
<td bgcolor="#CCFFFF" onclick="Sort('ORDERNUMBER
<td bgcolor="#CCFFFF" onclick="Sort('SLIMVMT')">
<td bgcolor="#CCFFFF" onclick="Sort('CUSTNAME')"
<td bgcolor="#CCFFFF" onclick="Sort('CITY')"><b>
<td bgcolor="#CCFFFF" onclick="Sort('STATE')"><b
<td bgcolor="#CCFFCC" onclick="Sort('PERSONOBTAI
<td bgcolor="#CCFFCC" onclick="Sort('SCACID')"><
<td bgcolor="#CCFFCC" onclick="Sort('FIRSTCARRIE
<td bgcolor="#CCFFCC" onclick="Sort('SECONDCARRI
<td bgcolor="#CCFFCC" onclick="Sort('THIRDCARRIE
<td bgcolor="#CCFFCC" onclick="Sort('PODRECEIVED
<td bgcolor="#CCFFCC" onclick="Sort('SLISHIPTOOS
<td onclick="Sort('OSCRECEIVED
<td onclick="Sort('COMMENTS')"
</tr>
<xsl:for-each select="./*[position() < 6 and position() > 0]">
<xsl:sort select="./*[1]" order="ascending" />
<tr>
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFFF"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td bgcolor="CCFFCC"> <xs
<td> <xsl:value-of select="OSCRECEIVEDDATE" /></td>
<td> <xsl:value-of select="COMMENTS" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
what do you want to do ??? retreive xsl:for-each nodes from this XSL document ???
maybe if you can try something like
Style.XMLDocument.selectNo des("//xsl :for-each" )
because "xsl:for-each" is the name of the tag, and "select" is an attribute.
and this will you will retreive the node and to access his attribute and set a value write like :
Style.XMLDocument.selectNo des("//xsl :for-each" ).setAttri bute "select", <<value>>
rgds
Style.XMLDocument.selectNo
because "xsl:for-each" is the name of the tag, and "select" is an attribute.
and this will you will retreive the node and to access his attribute and set a value write like :
Style.XMLDocument.selectNo
rgds
ASKER
I tried doing just //xsl:for-each and that returns as nothing as well. What I'm doing is that setting up paging of a table, so that it only display say 20 records per page and the user can move through the pages as needed.
Here is an example of the HTML page. Note you will need the latest version of the Microsoft XML parser for this work:
<HTML>
<Head>
<LINK rel="stylesheet" type="text/css" href="../General.css">
<Script language="vbscript">
option explicit
Dim iRecordsPerPage
iRecordsPerPage = 20
Function Window_Onload()
' Adjust the record level loop so that it displays our default number of records per page
Style.XMLDocument.SelectNo des("//xsl :for-each" )(1).value = "./*[position() < " & iRecordsPerPage + 1 & " and position() > 0]"
transform()
setPageCount()
End function
Function Transform()
'Transform the xml document and stylesheet and display the # of records
'per page
DisplayArea.innerHTML = xmlMasterData.transformNod e(Style.Do cumentElem ent)
RecordsPerPage.value = iRecordsPerPage
End function
Function redisplay(iPage)
'Transform the document and display status info
Dim sDisplay
Dim iPageCount
Dim iRecordCount
'Store status information for use after
'the transformation because it gets lost
'in the transformation
iPageCount = PageCount.innerHTML
iRecordCount = RecordCount.innerHTML
transform()
'Display status information
PageCount.innerHTML = iPageCount
RecordCount.innerHTML = iRecordCount
CurrentPage.innerHTML = iPage
end function
function Sort(sField)
'Change the sort order and redisplay
Dim sortField
Dim sortOrderAttribute
'Attach to the order-by attribute
set sortField = Style.XMLDocument.selectSi ngleNode(" //xsl:sort /@select")
'Attach to the sort order attribute
set sortOrderAttribute = Style.XMLDocument.selectSi ngleNode(" //xsl:sort /@order")
'If we are already sorting by sField
if sortField.value = sField or sortField.value = "./*[0]" then
'change the sort order
if sortOrderAttribute.value = "descending" then
sortOrderAttribute.value = "ascending"
else
sortOrderAttribute.value = "descending"
end if
else
'sort ascending
sortField.value = sField
sortOrderAttribute.value = "ascending"
end if
set sortField = nothing
set sortOrderAttribute = nothing
redisplay(CurrentPage.inne rHTML)
end function
function setRecordsPerPage()
'Reset the number of records per page
if isnumeric(RecordsPerPage.v alue) then
iRecordsPerPage = cint(RecordsPerPage.value)
window_onload
end if
end function
function setPageCount()
'Display page count status information
Dim iTotalRecords
PageCount.innerHTML = getNumberOfPages(iTotalRec ords)
RecordCount.innerHTML = iTotalRecords
CurrentPage.innerHTML = 1
end function
function getNumberOfPages(iTotalRec ords)
'Calculate and return the total number of pages
'and total number of records
Dim iPages
'Use the length property to get the record count
iTotalRecords = xmlMasterData.XMLDocument. selectNode s("/*/*"). length
'Calculate the total number of pages
iPages = iTotalRecords/iRecordsPerP age
if instr(iPages, ".") > 0 then
iPages = cint(left(iPages, instr(iPages, "."))) + 1
end if
getNumberOfPages = iPages
end function
function nextPage(iPage)
Dim sDisplay
Dim sDateRange
'Only make changes if we aren't on the last page
if cint(cstr(iPage) * iRecordsPerPage) < xmlMasterData.selectNodes( "/*/*").le ngth then
iPage = cint(iPage) + 1
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo des("//@On Click")(1) .value = "previousPage(" & iPage & ")"
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo des("//@On Click")(2) .value = "nextPage(" & iPage & ")"
'Set the new values for the record level loop
Style.XMLDocument.selectNo des("//xsl :for-each/ @select")( 1).value = "./*[position() <= " & (cstr(iPage) * iRecordsPerPage) & " and position() > " & (cint(iPage) - 1) * iRecordsPerPage & "]"
redisplay(iPage)
end if
end function
function previousPage(iPage)
Dim sDisplay
Dim sDateRange
'If we aren't on the first page
if iPage > 1 then
iPage = cint(iPage) - 1
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo des("//@On Click")(1) .value = "previousPage(" & iPage & ")"
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo des("//@On Click")(2) .value = "nextPage(" & iPage & ")"
'Set the new values for the record level loop
Style.XMLDocument.selectNo des("//xsl :for-each/ @select")( 1).value = "./*[position() <= " & (cstr(iPage) * iRecordsPerPage) & " and position() > " & (cint(iPage) - 1) * iRecordsPerPage & "]"
redisplay(iPage)
end if
end function
function FirstPage()
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo des("//@On Click")(1) .value = "previousPage(1)"
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo des("//@On Click")(2) .value = "nextPage(1)"
'Set the new values for the record level loop
Style.XMLDocument.selectNo des("//xsl :for-each/ @select")( 1).value = "./*[position() < " & iRecordsPerPage + 1 & " and position() > 0]"
transform()
setPageCount()
end function
function LastPage()
Dim iTotalPages
Dim iTotalRecords
'Calculate the number of pages
iTotalPages = getNumberOfPages(iTotalRec ords)
'Call next page, passing the total pages minus 1
nextPage(iTotalPages - 1)
end function
function EditPage(iPODID)
'We can't let anybody edit these PODs
EditPage = false
end function
</Script>
</Head>
<body>
<XML id='xmlMasterData'> <recordset><row><PODREQUES TID>17</PO DREQUESTID ><DATEREQU ESTED>2001 -06-14</DA TEREQUESTE D><PERSONR EQUESTED>P aul Cavacas</PERSONREQUESTED>< PLANTID>60 0</PLANTID ><SHIPDATE >2000-11-2 8</SHIPDAT E><DELIVER YDATE>2000 -11-30</DE LIVERYDATE ><ORDERNUM BER>224983 </ORDERNUM BER><SLIMV MT>AA20846 </SLIMVMT> <CUSTNAME> PUBLIX - BOYNTON BEACH</CUSTNAME><CITY>BOYN TON BEACH</CITY><STATE>FL</STA TE><PERSON OBTAINING> Paul Cavacas</PERSONOBTAINING>< SCACID>ANT T</SCACID> <FIRSTCARR IER>2001-0 4-05</FIRS TCARRIER>< PODRECEIVE DDATE>2001 -04-08</PO DRECEIVEDD ATE><SLISH IPTOOSCDAT E>2001-04- 09</SLISHI PTOOSCDATE ><OSCRECEI VEDDATE>20 01-07-12</ OSCRECEIVE DDATE><COM MENTS>Here are some comments.</COMMENTS></row> <row><PODR EQUESTID>1 8</PODREQU ESTID><DAT EREQUESTED >2001-06-1 5</DATEREQ UESTED><PE RSONREQUES TED>Paul Cavacas</PERSONREQUESTED>< PLANTID>60 0</PLANTID ><SHIPDATE >2000-12-0 1</SHIPDAT E><DELIVER YDATE>2000 -12-07</DE LIVERYDATE ><ORDERNUM BER>224982 </ORDERNUM BER><SLIMV MT>AA35678 </SLIMVMT> <CUSTNAME> MCLANE</CU STNAME><CI TY>BROOKHA VEN</CITY> <STATE>MS< /STATE><PE RSONOBTAIN ING>Paul Cavacas</PERSONOBTAINING>< SCACID>CEN F</SCACID> <FIRSTCARR IER>2001-0 4-05</FIRS TCARRIER>< SECONDCARR IER>2001-0 4-06</SECO NDCARRIER> <THIRDCARR IER>2001-0 4-07</THIR DCARRIER>< PODRECEIVE DDATE>2001 -04-08</PO DRECEIVEDD ATE><SLISH IPTOOSCDAT E>2001-04- 09</SLISHI PTOOSCDATE ><OSCRECEI VEDDATE>20 01-07-12</ OSCRECEIVE DDATE><COM MENTS>Done </COMMENTS ></row><ro w><PODREQU ESTID>14</ PODREQUEST ID><DATERE QUESTED>20 01-06-14</ DATEREQUES TED><PERSO NREQUESTED >Paul Cavacas</PERSONREQUESTED>< PLANTID>74 3</PLANTID ><SHIPDATE >2000-11-2 7</SHIPDAT E><DELIVER YDATE>2000 -11-28</DE LIVERYDATE ><ORDERNUM BER>224996 </ORDERNUM BER><SLIMV MT>AA18866 </SLIMVMT> <CUSTNAME> COASTAL PACIFIC FOOD DISTRIBUTORS</CUSTNAME><CI TY>STOCKTO N</CITY><S TATE>CA</S TATE><PERS ONOBTAININ G></PERSON OBTAINING> <SCACID>BS RK</SCACID ><COMMENTS >Here are some comments.</COMMENTS></row> <row><PODR EQUESTID>1 5</PODREQU ESTID><DAT EREQUESTED >2001-06-1 4</DATEREQ UESTED><PE RSONREQUES TED>Paul Cavacas</PERSONREQUESTED>< PLANTID>10 4</PLANTID ><SHIPDATE >2000-11-2 0</SHIPDAT E><ORDERNU MBER>22498 7</ORDERNU MBER><SLIM VMT></SLIM VMT><CUSTN AME>BIG Y FOODS INC</CUSTNAME><CITY>SPRING FIELD</CIT Y><STATE>M A</STATE>< PERSONOBTA INING>Paul Cavacas</PERSONOBTAINING>< SCACID>NCL S</SCACID> <FIRSTCARR IER>2001-0 4-05</FIRS TCARRIER>< SECONDCARR IER>2001-0 4-06</SECO NDCARRIER> <PODRECEIV EDDATE>200 1-04-08</P ODRECEIVED DATE><SLIS HIPTOOSCDA TE>2001-04 -09</SLISH IPTOOSCDAT E><OSCRECE IVEDDATE>2 001-07-12< /OSCRECEIV EDDATE></r ow><row><P ODREQUESTI D>16</PODR EQUESTID>< DATEREQUES TED>2001-0 6-14</DATE REQUESTED> <PERSONREQ UESTED>Pau l Cavacas</PERSONREQUESTED>< PLANTID>60 0</PLANTID ><SHIPDATE >2000-11-2 5</SHIPDAT E><ORDERNU MBER>22498 6</ORDERNU MBER><SLIM VMT>224986 </SLIMVMT> <CUSTNAME> THE HE BUTT GROC CO</CUSTNAME><CITY>SAN ANTONIO</CITY><STATE>TX</S TATE><PERS ONOBTAININ G>Paul Cavacas</PERSONOBTAINING>< SCACID>PIU P</SCACID> <FIRSTCARR IER>2001-0 4-05</FIRS TCARRIER>< SECONDCARR IER>2001-0 4-06</SECO NDCARRIER> <THIRDCARR IER>2001-0 4-07</THIR DCARRIER>< PODRECEIVE DDATE>2001 -04-08</PO DRECEIVEDD ATE><SLISH IPTOOSCDAT E>2001-04- 09</SLISHI PTOOSCDATE ><COMMENTS >More Comments for a POD</COMMENTS></row></reco rdset>
</XML><XML id='Style' src='../XSLT/AllPODS.xslt' ></XML><sp an id='DisplayArea'></span> </body>
</HTML>
Here is an example of the HTML page. Note you will need the latest version of the Microsoft XML parser for this work:
<HTML>
<Head>
<LINK rel="stylesheet" type="text/css" href="../General.css">
<Script language="vbscript">
option explicit
Dim iRecordsPerPage
iRecordsPerPage = 20
Function Window_Onload()
' Adjust the record level loop so that it displays our default number of records per page
Style.XMLDocument.SelectNo
transform()
setPageCount()
End function
Function Transform()
'Transform the xml document and stylesheet and display the # of records
'per page
DisplayArea.innerHTML = xmlMasterData.transformNod
RecordsPerPage.value = iRecordsPerPage
End function
Function redisplay(iPage)
'Transform the document and display status info
Dim sDisplay
Dim iPageCount
Dim iRecordCount
'Store status information for use after
'the transformation because it gets lost
'in the transformation
iPageCount = PageCount.innerHTML
iRecordCount = RecordCount.innerHTML
transform()
'Display status information
PageCount.innerHTML = iPageCount
RecordCount.innerHTML = iRecordCount
CurrentPage.innerHTML = iPage
end function
function Sort(sField)
'Change the sort order and redisplay
Dim sortField
Dim sortOrderAttribute
'Attach to the order-by attribute
set sortField = Style.XMLDocument.selectSi
'Attach to the sort order attribute
set sortOrderAttribute = Style.XMLDocument.selectSi
'If we are already sorting by sField
if sortField.value = sField or sortField.value = "./*[0]" then
'change the sort order
if sortOrderAttribute.value = "descending" then
sortOrderAttribute.value = "ascending"
else
sortOrderAttribute.value = "descending"
end if
else
'sort ascending
sortField.value = sField
sortOrderAttribute.value = "ascending"
end if
set sortField = nothing
set sortOrderAttribute = nothing
redisplay(CurrentPage.inne
end function
function setRecordsPerPage()
'Reset the number of records per page
if isnumeric(RecordsPerPage.v
iRecordsPerPage = cint(RecordsPerPage.value)
window_onload
end if
end function
function setPageCount()
'Display page count status information
Dim iTotalRecords
PageCount.innerHTML = getNumberOfPages(iTotalRec
RecordCount.innerHTML = iTotalRecords
CurrentPage.innerHTML = 1
end function
function getNumberOfPages(iTotalRec
'Calculate and return the total number of pages
'and total number of records
Dim iPages
'Use the length property to get the record count
iTotalRecords = xmlMasterData.XMLDocument.
'Calculate the total number of pages
iPages = iTotalRecords/iRecordsPerP
if instr(iPages, ".") > 0 then
iPages = cint(left(iPages, instr(iPages, "."))) + 1
end if
getNumberOfPages = iPages
end function
function nextPage(iPage)
Dim sDisplay
Dim sDateRange
'Only make changes if we aren't on the last page
if cint(cstr(iPage) * iRecordsPerPage) < xmlMasterData.selectNodes(
iPage = cint(iPage) + 1
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo
'Set the new values for the record level loop
Style.XMLDocument.selectNo
redisplay(iPage)
end if
end function
function previousPage(iPage)
Dim sDisplay
Dim sDateRange
'If we aren't on the first page
if iPage > 1 then
iPage = cint(iPage) - 1
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo
'Set the new values for the record level loop
Style.XMLDocument.selectNo
redisplay(iPage)
end if
end function
function FirstPage()
'Set the new onClick event value for the previous page button
Style.XMLDocument.selectNo
'Set the new onClick even value for the nextpage button
Style.XMLDocument.selectNo
'Set the new values for the record level loop
Style.XMLDocument.selectNo
transform()
setPageCount()
end function
function LastPage()
Dim iTotalPages
Dim iTotalRecords
'Calculate the number of pages
iTotalPages = getNumberOfPages(iTotalRec
'Call next page, passing the total pages minus 1
nextPage(iTotalPages - 1)
end function
function EditPage(iPODID)
'We can't let anybody edit these PODs
EditPage = false
end function
</Script>
</Head>
<body>
<XML id='xmlMasterData'> <recordset><row><PODREQUES
</XML><XML id='Style' src='../XSLT/AllPODS.xslt'
</HTML>
hmm . i think a know a better solution .. don't modify your xsl , let it as it is .. your problem is to load only 20 nodes from your xml .. how do you do that ?
You have your XML and you want to select from it only 20 records, "row" elements.
let's say you have also a pointer = page number
make a select for "//row" and you will retreive all row nodes. after that you will select just the nodes you want like this :
Dim rowNode
Dim rowNodes
Dim newXMLString ' here you will find 20 row nodes
Dim i ' counter
Dim k ' counter for the 20 records
Dim pageNumber ' page number
Dim pagesize ' page size = 20
pagesize = 20
pagenumber = 3
i = 1
k = 0
'will have to step over 20*2 = 60 rows
Set rowNodes = <yourXMLObject>.selctNodes ("//row")
newXMLString = "<recordset>"
For Each rowNode In rowNode
If i < pagesize*pagenumber Then
' do nothing
Else
k = k + 1
newXMLString = newXMLString & rowNode.xml
End If
i = i + 1
Next
newXMLString = newXMLString & "</recordset>"
and now in newXMLString string you have only 20 or less row
hope this will help
rgds
You have your XML and you want to select from it only 20 records, "row" elements.
let's say you have also a pointer = page number
make a select for "//row" and you will retreive all row nodes. after that you will select just the nodes you want like this :
Dim rowNode
Dim rowNodes
Dim newXMLString ' here you will find 20 row nodes
Dim i ' counter
Dim k ' counter for the 20 records
Dim pageNumber ' page number
Dim pagesize ' page size = 20
pagesize = 20
pagenumber = 3
i = 1
k = 0
'will have to step over 20*2 = 60 rows
Set rowNodes = <yourXMLObject>.selctNodes
newXMLString = "<recordset>"
For Each rowNode In rowNode
If i < pagesize*pagenumber Then
' do nothing
Else
k = k + 1
newXMLString = newXMLString & rowNode.xml
End If
i = i + 1
Next
newXMLString = newXMLString & "</recordset>"
and now in newXMLString string you have only 20 or less row
hope this will help
rgds
ASKER
I would rather return the whole XML to the client and let them handle it the page instead of having to continue to hit the server for each page.
and one more thing .. don't forget to test for
( K <= pagesize ) ... !!!!
( K <= pagesize ) ... !!!!
it's like when you are paging through a recordset ..
regarding your code the function :
Function Window_Onload()
' Adjust the record level loop so that it displays our default number of records per page
Style.XMLDocument.SelectNo des("//xsl :for-each" )(1).value = "./*[position() < " & iRecordsPerPage +
1 & " and position() > 0]"
transform()
setPageCount()
End function
you want to set the value for the "select" attribute . not like this , i told you :
Style.XMLDocument.selectNo des("//xsl :for-each" ).setAttri bute "select", "./*[position() < " & iRecordsPerPage +
1 & " and position() > 0]"
Function Window_Onload()
' Adjust the record level loop so that it displays our default number of records per page
Style.XMLDocument.SelectNo
1 & " and position() > 0]"
transform()
setPageCount()
End function
you want to set the value for the "select" attribute . not like this , i told you :
Style.XMLDocument.selectNo
1 & " and position() > 0]"
ASKER
Style.XMLDocument.selectNo des("//xsl :for-each" ).setAttri bute "select", "./*[position() < " & iRecordsPerPage
+
1 & " and position() > 0]"
doesn't work. This is still not returning anything.
+
1 & " and position() > 0]"
doesn't work. This is still not returning anything.
I tried your search , like this :
Dim obj
Set obj = Server.CreateObject("MSXML 2.DOMDocum ent")
obj.load Server.MapPath ("test.xsl")
Response.Write Server.HTMLEncode(obj.sele ctNodes("/ /xsl:for-e ach").item (0).xml)
Response.Write obj.selectNodes("//xsl:for -each").le ngth
where test.xsl is your XSL document.
Results -> 1 node !!!!
try to verify the results of your search
Dim obj
Set obj = Server.CreateObject("MSXML
obj.load Server.MapPath ("test.xsl")
Response.Write Server.HTMLEncode(obj.sele
Response.Write obj.selectNodes("//xsl:for
where test.xsl is your XSL document.
Results -> 1 node !!!!
try to verify the results of your search
ASKER
I copied your example above and got the expected results. Now you try using the HTML page that I posted and the XSLT source that I posted and you will see that it doesn't work when I do it this way.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You I've changed the rest of the code.
thnaks for the points :)