<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">> I am the client, i receive messages from the server.</span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">> this is a sample of the message I would receive</span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">> <?xml version="1.0" encoding="UTF-8" ?></span></p>
<p><span style="font-family:Monospace">> - <#> <Envelope</span></p>
<p><span style="font-family:Monospace">> xmlns:xsi="*http://www.w3.org/2001/XMLSchema-instance*"xsi:noNamespaceSchem</span></p>
<p><span style="font-family:Monospace">>aLocation ="*schema1.xsd*"></span></p>
<p><span style="font-family:Monospace">> - <#> <Header></span></p>
<p><span style="font-family:Monospace">> <tDateTime>2006-01-17T08:42:17+08:00</DateTime></span></p>
<p><span style="font-family:Monospace">> <data>hello world</data></span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">> </Header>- <#></span></p>
<p><span style="font-family:Monospace">> </Envelope></span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">></span></p>
<p><span style="font-family:Monospace">> So what is this entityresolver that you are talking about?? Could I use</span></p>
<p><span style="font-family:Monospace">> 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("/" + 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>