Tutorials to .com

Tutorials to .com » Asp » Xml » Filter records using xsl

Filter records using xsl

Print View , by: iSee ,Total views: 16 ,Word Count: 577 ,Date: Wed, 22 Apr 2009 Time: 8:49 AM

xml DataIsland recently with the javascript to use the standard expansion of the html form into a TABLE similar MSFlexGrid under windows with the same rich client behavior grid, update data, submitted to upload in order to reduce the size of the xml document, it will Binding of the original data set to add a tag node <RecordFlag>, only three types of value NEW, UPDATE, DEL, respectively, said his father used to the node is added or modified, or deleted before, and Prior to the adoption of xmlhttp From all the records added to filter out <RecordFlag>. In dealing with the screening process, I would like to use the javascript to simulate a filter algorithm, but a lot of data in the data island, the filter is very slow, so think from different angles, coupled with expert advice, the use of xsl to deal with the data Island, with fast speed to achieve a great deal of data on the selection process.
My xml structure is such
<field1> ...</ field1>
<field2> ...</ field2>
<field3> ...</ field3>
<fieldn> ...</ fieldn>
<field1> ...</ field1>
<field2> ...</ field2>
<field3> ...</ field3>
<fieldn> ...</ fieldn>
<RecordFlag> ...</ RecordFlag>
<! - tampered with the records of the node ->
</ root>
xsl file is as follows, the name of "select.xsl":
<? xml version = "1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "xml" omit-xml-declaration = "yes" indent = "yes"/>
<xsl:template match="node()">
<xsl:for-each select="...">
<! - here is the corresponding node name for each record, there can record ->
<xsl:if test="RecordFlag">
<! - here is to filter out the name of the tag node is RecordFlag ->
<xsl:copy-of select="."/>
</ xsl: if>
</ xsl: for-each>
</ xsl: copy>
</ xsl: template>
</ xsl: stylesheet>
Javascript achieved through the following conversion:
function getResultSet ()
var recordset = document.getElementById (you island id)
var xslselect = new ActiveXObject ( 'MSXML2.DOMDocument');
xslselect.async = false;
xslselect.load ( 'select.xsl');
var resultset = new ActiveXObject ( 'MSXML2.DOMDocument');
resultset.loadXML (recordset.xml)
/ / As the Island in the browser client does not support transformNode () method, so to use a
/ / Month to change the MSXML2DOM.
resultset.loadXML (resultset.transformNode (resultset));
return resultset;

Asp and XML related Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.