You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "jzwang (JIRA)" <ji...@apache.org> on 2008/08/25 04:59:44 UTC

[jira] Created: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
-------------------------------------------------------------------------------------------------------------------------------

                 Key: DIGESTER-128
                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
             Project: Commons Digester
          Issue Type: Bug
    Affects Versions: 1.7
         Environment: Windows XP
Eclipse 3.2
            Reporter: jzwang
            Priority: Critical


When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
My code is here.
-------------------- SampleDigester.java -------------------
import java.io.IOException;
import java.util.Hashtable;
import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

public class SampleDigester
{
  private Hashtable dataSources = new Hashtable();

  public static void main(String[] args)
  {
    SampleDigester sample = new SampleDigester();

    try
    {
      sample.run();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

  public void run() throws IOException, SAXException
  {
    Digester digester = new Digester();

    digester.push(this);

    digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
    digester.addCallParam("datasources/datasource/name", 0);
    digester.addCallParam("datasources/datasource/driver", 1);
    digester.addCallParam("datasources/datasource/url", 2);
    digester.addCallParam("datasources/datasource/username", 3);
    digester.addCallParam("datasources/datasource/password", 4);


//    digester.parse("datasource.xml"); // ok
    digester.parse("c:/tmp/中文/datasource.xml"); // failed
//    digester.parse("c:/tmp/a b/datasource.xml"); // ok
  }

  public void addDataSource(String name,
                            String driver,
                            String url,
                            String userName,
                            String password)
  {
    DataSource dataSource = new DataSource(name, driver,url, userName, password);
    dataSources.put(name, dataSource);
    System.out.println("DataSource added: " + name);
  }
}
--------------------------- DataSource.java ---------------------
public class DataSource
{
  private String name;
  private String driver;
  private String url;
  private String password;
  private String userName;

  public DataSource(String name, String driver, String url, String userName, String password)
  {
    this.name = name;
    this.driver = driver;
    this.url = url;
    this.userName = userName;
    this.password = password;
  }

  public String getName()
  {
    return name;
  }

  public String getDriver()
  {
    return driver;
  }

  public String getURL()
  {
    return url;
  }

  public String getPassword()
  {
    return password;
  }

  public String getUserName()
  {
    return userName;
  }
}
--------------------------- DataSource.xml -------------
<?xml version="1.0"?>
<datasources>
  <datasource>
    <name>HsqlDataSource</name>
    <driver>org.hsqldb.jdbcDriver</driver>
    <url>jdbc:hsqldb:hsql://localhost</url>
    <username>sa</username>
    <password></password>
  </datasource>
  <datasource>
      <name>OracleDataSource</name>
      <driver>oracle.jdbc.driver.OracleDriver</driver>
      <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
      <username>scott</username>
      <password>tiger</password>
  </datasource>
</datasources>
----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "jzwang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625272#action_12625272 ] 

jzwang commented on DIGESTER-128:
---------------------------------

Sorry for the noise.
I will try to do more research on it.
Thanks.


> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625263#action_12625263 ] 

Simon Kitching commented on DIGESTER-128:
-----------------------------------------

Have you tried calling this?
  Digester.parse("file:/C:/tmp/中文/datasource.xml")

Note that the method you are calling is documented as taking a URL:

public java.lang.Object parse(java.lang.String uri)
                       throws java.io.IOException,
                              org.xml.sax.SAXException

    Parse the content of the specified URI using this Digester. Returns the root element from the object stack (if any).

    Parameters:
        uri - URI containing the XML data to be parsed 

By the way, the string "file:/C:/tmp/..." is not actually a valid URL either. But the java library is reasonable relaxed about this. As long as
  new URL(someString)
doesn't throw an exception, that string will also be accepted by Digester - because Digester just calls the java standard libraries anyway (as the stack trace above shows).

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625278#action_12625278 ] 

Simon Kitching commented on DIGESTER-128:
-----------------------------------------

If the URL specification from the W3C organisation says that urls are allowed to have unicode characters, then this would be a bug in the java.net.URL class (and you should report it to Sun).

If the URL specification from the W3C organisation says that all non-ascii characters in a url must be "encoded" in some way, then this is a bug in your code, and you should correctly encode your url.

But it is definitely not a bug in Digester.

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625268#action_12625268 ] 

Simon Kitching commented on DIGESTER-128:
-----------------------------------------

Sorry, I can't help you with that. That is not a digester problem at all, just a problem getting the right URL format for reading data out of a jarfile.

I suggest you try just doing
  URL url = new URL(...);
  InputStream is = url.openStream();
  int firstChar = is.read();

Once you get that working correctly, then the same url should work ok with Digester.

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "jzwang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625275#action_12625275 ] 

jzwang commented on DIGESTER-128:
---------------------------------

I changed my test case as this.
digester.parse("jar:file:/C:/EAS/中文/temp/JZWANG-DESKTOP/1/default145610.jar!/com/sun/faces/standard-html-renderkit.xml");
Now I got the same exception as my real case.  But when I try to use directory name in English it worked.
So do you think it is a digester issue or other one?
--------------
java.net.MalformedURLException: no protocol: standard-html-renderkit-impl.xml
	at java.net.URL.<init>(URL.java:567)
	at java.net.URL.<init>(URL.java:464)
	at java.net.URL.<init>(URL.java:413)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:968)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:843)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:686)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2065)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2027)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDInternalSubset(XMLDTDScannerImpl.java:367)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:977)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
	at org.apache.commons.digester.Digester.parse(Digester.java:1704)
	at SampleDigester.run(SampleDigester.java:43)
	at SampleDigester.main(SampleDigester.java:18)


> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "jzwang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625260#action_12625260 ] 

jzwang commented on DIGESTER-128:
---------------------------------

Firstly I think usage for parse method is right.
digester.parse("c:/tmp/中文/datasource.xml");
Here we only need a location for a xml file.

Secondly the URL class in jdk can parse the URL correctly.
I can use this code to test.
URL url = new URL("file:/C:/tmp/中文/djc-setenv.sh"); // susscessfully
So this issue is not a jdk issue.

FYI, here is my call stack.
java.net.MalformedURLException: unknown protocol: c
	at java.net.URL.<init>(URL.java:574)
	at java.net.URL.<init>(URL.java:464)
	at java.net.URL.<init>(URL.java:413)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:968)
	at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
	at org.apache.commons.digester.Digester.parse(Digester.java:1704)
	at SampleDigester.run(SampleDigester.java:39)
	at SampleDigester.main(SampleDigester.java:16)

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "jzwang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625266#action_12625266 ] 

jzwang commented on DIGESTER-128:
---------------------------------

Yes, you are right.
When I try to use "file:/..." it worked.

Now here is my real call stack.
Can you give me some comments about it?
2008-08-22 17:56:32.812 WARN  main [ConfigureListener] Can't parse configuration file:jar:file:/C:/EAS/中文/temp/JZWANG-DESKTOP/1/default145610.jar!/com/sun/faces/standard-html-renderkit.xml
2008-08-22 17:56:32.812 WARN  main     Caused by: java.net.MalformedURLException: no protocol: standard-html-renderkit-impl.xml
2008-08-22 17:56:32.812 WARN  main     | at java.net.URL.<init>(URL.java:567)
2008-08-22 17:56:32.812 WARN  main     | at java.net.URL.<init>(URL.java:464)
2008-08-22 17:56:32.812 WARN  main     | at java.net.URL.<init>(URL.java:413)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDTDScannerImpl.startPE(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDTDScannerImpl.skipSeparator(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDInternalSubset(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
2008-08-22 17:56:32.812 WARN  main     | at org.apache.commons.digester.Digester.parse(Digester.java:1647)
2008-08-22 17:56:32.812 WARN  main     | at com.sun.faces.config.ConfigureListener.parse(ConfigureListener.java:1239)
2008-08-22 17:56:32.812 WARN  main     | at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:213)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
2008-08-22 17:56:32.812 WARN  main     | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
2008-08-22 17:56:32.812 WARN  main     | at com.sybase.djc.server.jetty.WebServer.addWebAppContext(WebServer.java:780)
2008-08-22 17:56:32.812 WARN  main     | at com.sybase.djc.server.jetty.WebServer.start(WebServer.java:358)
2008-08-22 17:56:32.812 WARN  main     | at com.sybase.djc.server.ApplicationServer.start(ApplicationServer.java:2053)
2008-08-22 17:56:32.812 WARN  main     | at com.sybase.djc.server.ApplicationServer.start(ApplicationServer.java:93)
2008-08-22 17:56:32.812 WARN  main     | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2008-08-22 17:56:32.812 WARN  main     | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2008-08-22 17:56:32.812 WARN  main     | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2008-08-22 17:56:32.812 WARN  main     | at java.lang.reflect.Method.invoke(Method.java:585)
20

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625259#action_12625259 ] 

Simon Kitching commented on DIGESTER-128:
-----------------------------------------

The string "c:/tmp/中文/datasource.xml" is not a URL.

A URL for a file will look like "file://.....". And I'm not sure that non-ascii characters are actually allowed in a URL at all. So I think that this exception is technically correct. Anyway, it is being thrown by the Java libraries, not Digester, so there is not much that Digester code can do about it.

I do vaguely remember hearing something about the official specification for URLs having been updated to allow unicode, but even if that is true it will have only been recently. So you will probably need to look up the official rules for URLs and then build an appropriately-encoded string.

Anyway, Digester already has method
  Digester.parse(File f)
which is probably the right thing for you to use here, ie create a File object to wrap your filename-string rather than trying to interpret it as a URL.

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "jzwang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625283#action_12625283 ] 

jzwang commented on DIGESTER-128:
---------------------------------

OK.
I have filed a cr to jdk.
And thank you again.

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.

Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simon Kitching closed DIGESTER-128.
-----------------------------------

    Resolution: Invalid

Not a bug.

> When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.