<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:11pt;font-family:Myriad Pro">
<p><span style="font-family:Monospace">Am Mittwoch, 10. Mai 2006 12:29 schrieb Søren Faltz:</span></p>
<p><span style="font-family:Monospace">&gt; I am the client, i receive messages from the server.</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt; this is a sample of the message I would receive</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt;   &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span></p>
<p><span style="font-family:Monospace">&gt;   - &lt;#&gt; &lt;Envelope</span></p>
<p><span style="font-family:Monospace">&gt; xmlns:xsi=&quot;*http://www.w3.org/2001/XMLSchema-instance*&quot;xsi:noNamespaceSchem</span></p>
<p><span style="font-family:Monospace">&gt;aLocation =&quot;*schema1.xsd*&quot;&gt;</span></p>
<p><span style="font-family:Monospace">&gt;  - &lt;#&gt; &lt;Header&gt;</span></p>
<p><span style="font-family:Monospace">&gt;    &lt;tDateTime&gt;2006-01-17T08:42:17+08:00&lt;/DateTime&gt;</span></p>
<p><span style="font-family:Monospace">&gt; &lt;data&gt;hello world&lt;/data&gt;</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt; &lt;/Header&gt;- &lt;#&gt;</span></p>
<p><span style="font-family:Monospace">&gt; &lt;/Envelope&gt;</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt;</span></p>
<p><span style="font-family:Monospace">&gt; So what is this entityresolver that you are talking about?? Could I use</span></p>
<p><span style="font-family:Monospace">&gt; that to determine the correct schema???</span></p>
<p></p>
<p><span style="font-family:Monospace">http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/EntityResolver.html</span></p>
<p></p>
<p><span style="font-family:Monospace">Set the Entity resolver used by the SAXBuilder:</span></p>
<p></p>
<p><span style="font-family:Monospace">builder.setEntityResolver( new MyEntityResolver() );</span></p>
<p></p>
<p><span style="font-family:Monospace">Yes, implement the method resolveEntity like this:</span></p>
<p></p>
<p><span style="font-family:Monospace">public InputSource resolveEntity(String publicId, String systemId) throws org.xml.sax.SAXException, java.io.IOException {</span></p>
<p><span style="font-family:Monospace">        if (systemId == null) {</span></p>
<p><span style="font-family:Monospace">            return null; // Use default resolver</span></p>
<p><span style="font-family:Monospace">        }</span></p>
<p><span style="font-family:Monospace">        //try to read schema file from classpath</span></p>
<p><span style="font-family:Monospace">        InputStream is = this.getClass().getResourceAsStream(&quot;/&quot; + systemId);</span></p>
<p><span style="font-family:Monospace">        if (is == null) {</span></p>
<p><span style="font-family:Monospace">            return null; // Use default resolver</span></p>
<p><span style="font-family:Monospace">        }</span></p>
<p><span style="font-family:Monospace">        return new InputSource(is);</span></p>
<p><span style="font-family:Monospace">}</span></p>
<p></p>
<p><span style="font-family:Monospace">If this solves the problem you some kind of cache for the getResourceAsStream call and make the EntityResolver a stateless Singleton to enhance perfomance.</span></p>
<p></p>
<p><span style="font-family:Monospace">regards</span></p>
<p></p>
<p><span style="font-family:Monospace">Thomas</span></p>
</body></html>