W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > January 2008

NumberFormatException in EXTERNAL_RESOURCES

From: Guido García Bernardo <ggarciab@itdeusto.com>
Date: Wed, 30 Jan 2008 10:23:57 +0100
Message-ID: <47A0422D.9000100@itdeusto.com>
To: public-mobileok-checker <public-mobileok-checker@w3.org>

Hi,

I hope I'm wrong, but I think there is a little bug in the 
EXTERNAL_RESOURCES test.
This is the stack trace I get.  You can reproduce it by running the 
Tester against http://www.htmlpoint.com/guida/html_11.htm

Exception in thread "main" java.lang.NumberFormatException: For input 
string: "2
                        "
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at 
org.w3c.mwi.mobileok.basic.TestSubResult.<init>(TestSubResult.java:40)
    at 
org.w3c.mwi.mobileok.basic.AbstractTestImplementation.runTest(AbstractTestImplementation.java:28)
    ...

The latest ExternalResourcesTest.xsl in the CVS (1.4) is

...
    <xsl:call-template name="result">
        <xsl:with-param name="name">
            EXTERNAL_RESOURCES-2
        </xsl:with-param>
        ...
    </xsl:call-template>
...

so the following code doesn't work, because the "name" value is 
""\n\t\t\t\t\t\t\tEXTERNAL_RESOURCES-2\n\t\t\t\t\t\t" instead of 
"EXTERNAL_RESOURCES-2"

...
TestSubResult(final Element result) {
        final String name = result.getAttribute("name");
        final int dash = name.indexOf((int) '-');
        this.subResultID = Integer.parseInt(name.substring(dash + 1));  
<= NumberFormatException
                ...

You could fix it by omitting the leading and trailing tabs and line 
breaks in the XSL (or by changing the Java code):

...
    <xsl:call-template name="result">
        <xsl:with-param name="name">EXTERNAL_RESOURCES-2</xsl:with-param>
        ...
    </xsl:call-template>
...

Maybe the same is happening in other tests.

Regards,
guido.
Received on Wednesday, 30 January 2008 09:24:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2008 09:24:19 GMT