How to skip DTD verification when www.mybatis.org is down?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to skip DTD verification when www.mybatis.org is down?

Ian@Sg
Hi All

Seems like SqlSessionFactoryBuilder will always check for http://www.mybatis.org/mybatis-3-config.dtd.

Is there anyway we can skip this validation especially when www.mybatis.org is down?

Regards
Ian Lim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to skip DTD verification when www.mybatis.org is down?

Clinton Begin
Administrator
It should be using the entity resolver and the DTD in the JAR file... of course that depends on the underlying XML parser, which must support entity resolvers.  

If you're in a pinch, you can relocate the DTDs wherever you want, but you must then change the URL in your XML files... pretty easy to do.

Cheers,
Clinton


On Wed, Dec 5, 2012 at 7:59 PM, Ian@Sg <[hidden email]> wrote:
Hi All

Seems like SqlSessionFactoryBuilder will always check for http://www.mybatis.org/mybatis-3-config.dtd.

Is there anyway we can skip this validation especially when www.mybatis.org is down?

Regards
Ian Lim

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to skip DTD verification when www.mybatis.org is down?

Ikchan Sim
 
1. Download local file... for example:
src/org/apache/ibatis/builder/xml/mybatis-3-config.dtd
 
2. Modifyed declar XML DTD
 
<!-- Before -->

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

 
 
<!-- After -->
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"org/apache/ibatis/builder/xml/mybatis-3-config.dtd">
 
 
3. Introduce classes relation...
Modified external declar DTD by 'XMLMapperEntityResolver Class' when load mybatis configuration XML File.
source file path: org.apache.ibatis.builder.xml.XMLMapperEntityResolver.java

 

reference class note

-------------------------------------------------------------------------------

public InputSource resolveEntity(String publicId, String systemId)

        throws SAXException {

    if (publicId != null) publicId = publicId.toUpperCase(Locale.ENGLISH);

    if (systemId != null) systemId = systemId.toUpperCase(Locale.ENGLISH);

    InputSource source = null;

    try {

        String path = doctypeMap.get(publicId);

        source = getInputSource(path, source);

        if (source == null) {

            path = doctypeMap.get(systemId);

            source = getInputSource(path, source);

        }

    } catch (Exception e) {

        throw new SAXException(e.toString());

    }

    System.out.println("System ID: [" + systemId + "]\r\n Resource: [" + source + "]");

    return source;

}

 private InputSource getInputSource(String path, InputSource source) {

    if (path != null) {

        InputStream in;

        try {

            in = Resources.getResourceAsStream(path);

            source = new InputSource(in);

        } catch (IOException e) {

            // ignore, null is ok

        }

    }

    return source;

}

-------------------------------------------------------------------------------

 

 

this is console log...

-------------------------------------------------------------------------------

System ID: [FILE:///C:/WORKSPACE_MYBATIS/HELLOMYBATIS/ORG/APACHE/IBATIS/BUILDER/XML/MYBATIS-3-CONFIG.DTD]

Resource: [RESOURCE:org.xml.sax.InputSource@1ecfeb]

-------------------------------------------------------------------------------

Good Luck ! 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to skip DTD verification when www.mybatis.org is down?

Eduardo Macarron
Before doing any modification to the DTD make sure that the XML header is this:

 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

And NOT this (note the extra www.)

 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-config.dtd">

Then try again.

2012/12/7 Ikchan Sim <[hidden email]>:

> XML System Indicator -> http://mybatis.org/dtd/mybatis-3-config.dtd
>
> 1. Download local file... for example:
> src/org/apache/ibatis/builder/xml/mybatis-3-config.dtd
>
> 2. Modifyed declar XML DTD
>
> <!-- Before -->
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
>
> "http://mybatis.org/dtd/mybatis-3-config.dtd">
>
>
> <!-- After -->
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
>
> "org/apache/ibatis/builder/xml/mybatis-3-config.dtd">
>
>
> 3. Introduce classes relation...
> Modified external declar DTD by 'XMLMapperEntityResolver Class' when load
> mybatis configuration XML File.
> source file path: org.apache.ibatis.builder.xml.XMLMapperEntityResolver.java
>
>
>
> reference class note
>
> -------------------------------------------------------------------------------
>
> public InputSource resolveEntity(String publicId, String systemId)
>
>         throws SAXException {
>
>     if (publicId != null) publicId = publicId.toUpperCase(Locale.ENGLISH);
>
>     if (systemId != null) systemId = systemId.toUpperCase(Locale.ENGLISH);
>
>     InputSource source = null;
>
>     try {
>
>         String path = doctypeMap.get(publicId);
>
>         source = getInputSource(path, source);
>
>         if (source == null) {
>
>             path = doctypeMap.get(systemId);
>
>             source = getInputSource(path, source);
>
>         }
>
>     } catch (Exception e) {
>
>         throw new SAXException(e.toString());
>
>     }
>
>     System.out.println("System ID: [" + systemId + "]\r\n Resource: [" +
> source + "]");
>
>     return source;
>
> }
>
>  private InputSource getInputSource(String path, InputSource source) {
>
>     if (path != null) {
>
>         InputStream in;
>
>         try {
>
>             in = Resources.getResourceAsStream(path);
>
>             source = new InputSource(in);
>
>         } catch (IOException e) {
>
>             // ignore, null is ok
>
>         }
>
>     }
>
>     return source;
>
> }
>
> -------------------------------------------------------------------------------
>
>
>
>
>
> this is console log...
>
> -------------------------------------------------------------------------------
>
> System ID:
> [FILE:///C:/WORKSPACE_MYBATIS/HELLOMYBATIS/ORG/APACHE/IBATIS/BUILDER/XML/MYBATIS-3-CONFIG.DTD]
>
> Resource: [RESOURCE:org.xml.sax.InputSource@1ecfeb]
>
> -------------------------------------------------------------------------------
>
> Good Luck !
Loading...