[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-j-dev
Subject:    Re: AW: xerces ignores reader.setProperty(SCHEMA_LOCATION_PROPERTY,"path/to/xsd") -
From:       Michael Glavassevich <mrglavas () ca ! ibm ! com>
Date:       2011-08-11 14:02:12
Message-ID: OF2F9270A5.02AFADDC-ON852578E9.004BC110-852578E9.004D1FA7 () ca ! ibm ! com
[Download RAW message or body]

Or just pass the systemId directly to the InputSource (i.e. new InputSource
(systemId)) and let the parser deal with the InputStream creation. This
makes it possible for the parser to resolve relative URIs which may appear
in the document you're returning from the resolver. If you only provide an
InputStream the base URI is lost.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Papendieck, Thomas" <Thomas.Papendieck@opitz-consulting.com> wrote on
08/11/2011 03:55:38 AM:

> solution is:
> InputSource(new FileInputStream(new File(new URI(systemId))));
>
> bye
> Thomas
> ________________________________________
> Von: Papendieck, Thomas [Thomas.Papendieck@opitz-consulting.com]
> Gesendet: Donnerstag, 11. August 2011 09:12
> Bis: j-users@xerces.apache.org
> Betreff: AW: xerces ignores reader.setProperty
> (SCHEMA_LOCATION_PROPERTY,"path/to/xsd")
>
> Hello,
>
> unfortunately John's Idea does not work because 'resolveEntity' is
> not called in my implementation.
>
> Where do I look next for a solution?
>
>
> > reader.setEntityResolver(new EntityResolver() {
> >
> >       @Override
> >        public InputSource resolveEntity(String publicId, String
systemId)
> >                        throws SAXException, IOException {
> >                InputSource result = null;
> >                // result = get the file from disk or however you
> need to do it ();
> >                return result;
> >        }
> >});
>
> bye
> Thomas
> ________________________________________
> Von: Newman, John W [newmanjw@d3onc.com]
> Gesendet: Mittwoch, 10. August 2011 19:05
> Bis: j-users@xerces.apache.org
> Betreff: RE: xerces ignores reader.setProperty
> (SCHEMA_LOCATION_PROPERTY,"path/to/xsd")
>
> I believe so yes .. but I'm not 100%
>
> Fire that up in the debugger and see what you get.   Or just add
> some log statements to see when it's getting called and what values
> you're getting for public id / system id
>
> -----Original Message-----
> From: Papendieck, Thomas [mailto:Thomas.Papendieck@opitz-consulting.com]
> Sent: Wednesday, August 10, 2011 1:03 PM
> To: j-users@xerces.apache.org
> Subject: AW: xerces ignores reader.setProperty
> (SCHEMA_LOCATION_PROPERTY,"path/to/xsd")
>
> Hello John,
>
> that was fast... ;o)
>
> >  public InputSource resolveEntity(String publicId, String systemId)
> Am I right that 'systemId' is (in my case) the path to the xsd as
> found in the 'xsi:schemaLocation' attribute?
>
> bye
> Thomas
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
[Attachment #3 (text/html)]

<html><body>
<p><tt>Or just pass the systemId directly to the InputSource (i.e. new \
InputSource(systemId)) and let the parser deal with the InputStream creation. This \
makes it possible for the parser to resolve relative URIs which may appear in the \
document you're returning from the resolver. If you only provide an InputStream the \
base URI is lost.</tt><br> <br>
<tt>Michael Glavassevich<br>
XML Parser Development<br>
IBM Toronto Lab<br>
E-mail: mrglavas@ca.ibm.com</tt><br>
<tt>E-mail: mrglavas@apache.org</tt><br>
<br>
<tt>&quot;Papendieck, Thomas&quot; &lt;Thomas.Papendieck@opitz-consulting.com&gt; \
wrote on 08/11/2011 03:55:38 AM:<br> <br>
&gt; solution is:<br>
&gt; InputSource(new FileInputStream(new File(new URI(systemId))));<br>
&gt; <br>
&gt; bye<br>
&gt; Thomas<br>
&gt; ________________________________________<br>
&gt; Von: Papendieck, Thomas [Thomas.Papendieck@opitz-consulting.com]<br>
&gt; Gesendet: Donnerstag, 11. August 2011 09:12<br>
&gt; Bis: j-users@xerces.apache.org<br>
&gt; Betreff: AW: xerces ignores reader.setProperty<br>
&gt; (SCHEMA_LOCATION_PROPERTY,&quot;path/to/xsd&quot;)<br>
&gt; <br>
&gt; Hello,<br>
&gt; <br>
&gt; unfortunately John's Idea does not work because 'resolveEntity' is <br>
&gt; not called in my implementation.<br>
&gt; <br>
&gt; Where do I look next for a solution?<br>
&gt; <br>
&gt; <br>
&gt; &gt; reader.setEntityResolver(new EntityResolver() {<br>
&gt; &gt;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; @Override<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;public InputSource resolveEntity(String \
publicId, String systemId)<br> &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throws SAXException, IOException {<br> &gt; \
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InputSource result = \
null;<br> &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// result \
= get the file from disk or however you <br> &gt; need to do it ();<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return result;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&gt; &gt;});<br>
&gt; <br>
&gt; bye<br>
&gt; Thomas<br>
&gt; ________________________________________<br>
&gt; Von: Newman, John W [newmanjw@d3onc.com]<br>
&gt; Gesendet: Mittwoch, 10. August 2011 19:05<br>
&gt; Bis: j-users@xerces.apache.org<br>
&gt; Betreff: RE: xerces ignores reader.setProperty<br>
&gt; (SCHEMA_LOCATION_PROPERTY,&quot;path/to/xsd&quot;)<br>
&gt; <br>
&gt; I believe so yes .. but I'm not 100%<br>
&gt; <br>
&gt; Fire that up in the debugger and see what you get. &nbsp; Or just add <br>
&gt; some log statements to see when it's getting called and what values <br>
&gt; you're getting for public id / system id<br>
&gt; <br>
&gt; -----Original Message-----<br>
&gt; From: Papendieck, Thomas [<a \
href="mailto:Thomas.Papendieck@opitz-consulting.com">mailto:Thomas.Papendieck@opitz-consulting.com</a>]<br>
 &gt; Sent: Wednesday, August 10, 2011 1:03 PM<br>
&gt; To: j-users@xerces.apache.org<br>
&gt; Subject: AW: xerces ignores reader.setProperty<br>
&gt; (SCHEMA_LOCATION_PROPERTY,&quot;path/to/xsd&quot;)<br>
&gt; <br>
&gt; Hello John,<br>
&gt; <br>
&gt; that was fast... ;o)<br>
&gt; <br>
&gt; &gt; &nbsp;public InputSource resolveEntity(String publicId, String \
systemId)<br> &gt; Am I right that 'systemId' is (in my case) the path to the xsd as \
<br> &gt; found in the 'xsi:schemaLocation' attribute?<br>
&gt; <br>
&gt; bye<br>
&gt; Thomas<br>
&gt; ---------------------------------------------------------------------<br>
&gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org<br>
&gt; For additional commands, e-mail: j-users-help@xerces.apache.org<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org<br>
&gt; For additional commands, e-mail: j-users-help@xerces.apache.org<br>
&gt; <br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org<br>
&gt; For additional commands, e-mail: j-users-help@xerces.apache.org<br>
&gt; <br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org<br>
&gt; For additional commands, e-mail: j-users-help@xerces.apache.org</tt><tt><br>
</tt></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic