Subject: RE: [xsl] Re:Re:How to simplify the xslt expression for multiple conditions. From: "Yang" <sfyang@xxxxxxxxxxxxx> Date: Wed, 30 May 2001 14:38:48 +0800 |
Hi, Jeni, Your nice explanation about using xml serilization as xml argument in javascript function is very helpful. >So, in the call to changePage(), you need to pass the serialised XML >that you want to transform as the second argument. You don't show the >part where you do it; it needs to looks something like: > changePage(<xsl:value-of select="$pagenumber + 1" />, '<xsl:call-template name="js-escape"> <xsl:with-param name="string"> <xsl:call-template name="serialiseXML"> <xsl:with-param name="originalDoc" select="/" /> </xsl:call-template> </xsl:with-param> </xsl:call-template>', 'style.xsl'); I find out two interesting things which you might like to know; 1 The js-escape template seems to omit the xml-declaration while producing the serialised XML. Since a part of xml is related to BIG5 , I must have this PI built in, such as <?xml version="1.0" encoding="big5"?> What is remedy to js-escape template? 2. It seems to me there is size limitation when using serialized XML as javascript augument. To prove this point, I keep adding **line** element into xml file. At certain point, the page change function becomes unfunctional and look like to be locked. Could you see what is caused. xml, xsl are listed below for fyi. >In fact, since you *always* want the second argument to be this >particular set of XML, you could hardcode it into the definition of >the Javascript function rather than pass it as a variable. I have a hard time to understand what is the phrase saying: ** you could the hardcode it into the definition of .... *** Are you suggesting that once I loadXML xml doc., and saved it as a global variable, then when doing the sequent paging, only I have to do is to use .addparam for new page number and display the output. Thanks again for your help. Sun-fu Yang ** xml ** <?xml version="1.0" ?> <?xml-stylesheet href="test.xsl" type="text/xsl"?> <docs > <line CustomerCode="AAA" SalesOrderNo="B001-1-0101110093"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101110094"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101110095"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101110096"/> <line CustomerCode="CCC" SalesOrderNo="B001-1-0101110097"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150120"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150122"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150123"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150122"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150123"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> <line CustomerCode="EEE" SalesOrderNo="B001-1-0101150122"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150123"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150122"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150123"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> <line CustomerCode="EEE" SalesOrderNo="B001-1-0101150128"/> <line CustomerCode="AAA" SalesOrderNo="B001-1-0101150123"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="DDD" SalesOrderNo="A001-1-0101170004"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> <line CustomerCode="EEE" SalesOrderNo="B001-1-0101150122"/> <line CustomerCode="BBB" SalesOrderNo="B001-1-0101150121"/> ** Adding one more piece of **line** data here, the size will disable the paging function *** </docs> ** xsl *** <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" > <xsl:include href="PagesXML.xsl" /> <xsl:output method="xml" indent="yes"/> <xsl:key name="Listings" match="line" use="@CustomerCode" /> <xsl:key name="salesNo" match="line" use="concat(@CustomerCode,'::',@SalesOrderNo)"/> <xsl:param name="month" select="''"/> <xsl:param name="space" select="2"/> <xsl:param name="pagenumber" select="1"/> <xsl:param name="start2" select="($pagenumber - 1) * $space" /> <xsl:param name="end2" select="$pagenumber * $space + 1" /> <!-- rtf-rows template - filtering, normalization of xml doc--> <xsl:template name="rtf-rows"> <xsl:param name="source"/> <rowset> <xsl:apply-templates select="$source[substring(@SalesOrderNo[$month], 10, 2) = $month]" /> </rowset> </xsl:template> <xsl:template match="line"> <line> <xsl:apply-templates select="@*|node()"/> </line> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{name()}"> <xsl:value-of select="normalize-space(.)"/> </xsl:attribute> </xsl:template> <xsl:template match="/"> <head> <script language="javascript" > function changePageXML(number,xmlfile,xslfile,pageParam,space){ XMLDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument'); XMLDOM.async = false; XMLDOM.loadXML(xmlfile); XSLTDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument'); XSLTDOM.async = false; XSLTDOM.load(xslfile); XSLStylesheet = new ActiveXObject('Msxml2.XSLTemplate'); XSLStylesheet.stylesheet = XSLTDOM; XSLTProcessor = XSLStylesheet.createProcessor(); XSLTProcessor.input = XMLDOM; XSLTProcessor.addParameter('xmlid', xmlfile); XSLTProcessor.addParameter('space', space); XSLTProcessor.addParameter('pageParam', pageParam); XSLTProcessor.addParameter('pagenumber2', number); XSLTProcessor.addParameter('pagenumber', number); XSLTProcessor.transform(); try{ content.innerHTML=XSLTProcessor.output; } catch(e){ document.open(); document.write(XSLTProcessor.output); document.close(); } } </script> </head> <xsl:variable name="rows-rtf"> <xsl:call-template name="rtf-rows"> <xsl:with-param name="source" select="//line"/> </xsl:call-template> </xsl:variable> <xsl:variable name="originalDoc" select="msxsl:node-set($rows-rtf)/rowset"/> <xsl:variable name="MSource" select="$originalDoc/line"/> <xsl:if test="string($month)"><xsl:value-of select="concat('Month :',$month)"/></xsl:if> <!-- get the unique set of @CustomerCode and saved as rtf --> <xsl:variable name="docsx"> <xsl:for-each select="$MSource[generate-id(.)=generate-id(key('Listings',@CustomerCode)[1] )]"> <xsl:sort select="@CustomerCode"/> <pdata> <xsl:value-of select="@CustomerCode"/><br/> </pdata> </xsl:for-each> </xsl:variable> <xsl:variable name="nodeset" select="msxsl:node-set($docsx)/pdata"/> <!-- prepare the Pages mechanism --> <xsl:call-template name="PagesXML"> <xsl:with-param name="element" select="$nodeset"/> <xsl:with-param name="pagenumber" select="$pagenumber" /> <xsl:with-param name="space" select="$space"/> <xsl:with-param name="xmlfile" select="$originalDoc"/> <xsl:with-param name="xslfile" select="'test.xsl'"/> <xsl:with-param name="pageParam" select="''"/> </xsl:call-template> <!-- display the outputs --> <xsl:call-template name="outdoc2"> <xsl:with-param name="start" select="$start2"/> <xsl:with-param name="end" select="$end2"/> <xsl:with-param name="nodeset" select="$nodeset"/> <xsl:with-param name="originalDoc" select="$originalDoc"/> </xsl:call-template> </xsl:template> <!-- output template --> <xsl:template name="outdoc2"> <xsl:param name="start" /> <xsl:param name="end" /> <xsl:param name="nodeset"/> <xsl:param name="originalDoc"/> <center> <!-- using the group by postion to display the section of outputs --> <xsl:for-each select="$nodeset[position() >$start and position() < ($end)]"> <xsl:value-of select="position() + $start"/> <xsl:variable name="thisPP" select="."/>   <xsl:value-of select="$thisPP"/><br/> <table> <xsl:for-each select="$originalDoc"> <tr> <xsl:for-each select="key('Listings',$thisPP)"> <td><xsl:value-of select="@SalesOrderNo"/></td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:for-each> </center> <br/> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re:Re:How to simplify the, Jeni Tennison | Thread | Re: [xsl] Re:Re:How to simplify the, Jeni Tennison |
[xsl] How to avoid duplicated items, Ramnivas Laddad | Date | [xsl] Entity Reference Questions, Albert Tsun |
Month |