GNOME Bugzilla – Bug 319040
ceiling() of xsl's function is wrong
Last modified: 2005-10-19 05:40:49 UTC
Please describe the problem: ceiling(174733 div 1024) I wished: 174733/1024=170.6376953125 so, although result of ceiling() is "171", it returned "070". Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Please provide a test case - e.g. a minimal stylesheet demonstrating the problem. Also please state what operating system and library is being used. Bill
<?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jpopc="http://www.jpo.go.jp" > <xsl:output method="html" encoding="UTF-16"/> *******************Abbreviation on the way*************** <!-- ========================================================== jpopc:size ===========================================================--> <xsl:template match="jpopc:size"> <xsl:variable name= "size_kb"> <xsl:value-of select="ceiling(. div 1024)" /> </xsl:variable> <xsl:choose> <xsl:when test="(. ='')or(round(.) ='0')"> <xsl:value-of select="'00000'"/> </xsl:when> <xsl:when test="string-length($size_kb) < 6"> <xsl:call-template name="零埋め"> <xsl:with-param name="i" select="6 - string-length($size_kb)" /> <xsl:with-param name="count" select="1" /> </xsl:call-template> <xsl:value-of select="$size_kb"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'-----'"/> </xsl:otherwise> </xsl:choose> </xsl:template> ****************************************************************** My xml follows: <?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE jpopc:procedure SYSTEM "v4crc00.dtd"> <jpopc:procedure xmlns:jpopc="http://www.jpo.go.jp"> <jpopc:document-type jpopc:unconfirmed-state="0">012010</jpopc:document-type> <jpopc:computer-name>FURUMI2-PC</jpopc:computer-name> <jpopc:user-name>t-furumi</jpopc:user-name> <jpopc:distinction-number></jpopc:distinction-number> <jpopc:relation-file> <jpopc:application-receipt-list></jpopc:application-receipt-list> </jpopc:relation-file> <jpopc:procedure-infomation> <jpopc:result> <jpopc:software-message>正常</jpopc:software-message> <jpopc:communication-result></jpopc:communication-result> <jpopc:fd-and-cdr></jpopc:fd-and-cdr> </jpopc:result> <jpopc:law>1</jpopc:law> <jpopc:document-name jpopc:document-code="A1523">手続補正書</jpopc:document- name> <jpopc:file-reference-id>A-63-1-A</jpopc:file-reference-id> <jpopc:invention-title></jpopc:invention-title> <jpopc:application-reference> <jpopc:registration-number></jpopc:registration-number> <jpopc:application-number>2000123456</jpopc:application-number> <jpopc:application-date>19990110</jpopc:application-date> <jpopc:international-application-number></jpopc:international-application- number> <jpopc:international-application-date></jpopc:international-application- date> <jpopc:reference-id>G2000-0001</jpopc:reference-id> <jpopc:appeal-reference-number>200012345</jpopc:appeal-reference-number> <jpopc:appeal-reference-date>20000104</jpopc:appeal-reference-date> <jpopc:number-of-annexation></jpopc:number-of-annexation> </jpopc:application-reference> <jpopc:submission-date> <jpopc:date>20030701</jpopc:date> <jpopc:time></jpopc:time> </jpopc:submission-date> <jpopc:page></jpopc:page> <jpopc:image-total>70</jpopc:image-total> <jpopc:size>174733</jpopc:size> <jpopc:receipt-number></jpopc:receipt-number> <jpopc:wad-message-digest-compare></jpopc:wad-message-digest-compare> ************************************************************** DTD: <!ELEMENT jpopc:size ( #PCDATA ) >
Sorry, but what you have provided is not sufficient. The stylesheet is not complete and cannot be used in it's current state; the xml file is also not complete, and also (because of the special characters) would have to be included as an attachment (rather than just text). I suspect that your trouble is really not a problem with 'ceiling', but rather a problem with your <xsl:call-template name="零埋め"> (which was not included). The reason I suspect that is because the following minimal stylesheet: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="size"> <xsl:variable name= "size_kb"> <xsl:value-of select="ceiling(. div 1024)" /> </xsl:variable> <xsl:value-of select="$size_kb"/> </xsl:template> </xsl:stylesheet> when processed against a corresponding minimal test file: <root> <size>1234</size> <size>174733</size> </root> produces the following: bill@billsuper ~/gnomecvs/work $ xsltproc bug.xsl bug.xml <?xml version="1.0"?> 2 171 which is exactly what is expected. If you still believe there is a problem within the library, please provide a complete test case which demonstrates it. Bill
I found bug of xsl. Thanks for your advice.