Hi Stephen, Werner
Thanks for your help. Looks like things are moving though with hiccups!
Here is my code, which I use to unmarshall the xml from the server:
String xml = server.get(OBJECT_ID);
....
Mapping mapping = new Mapping();
mapping.loadMapping("event-mapping.xml");
Unmarshaller um1 = new Unmarshaller();
um1.setMapping(mapping);
//code suggested by Stephen
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating( false );
XMLReader xmlReader = factory.newSAXParser().getXMLReader();
xmlReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
false );
UnmarshalHandler handler = um1.createHandler();
xmlReader.setContentHandler( handler );
xmlReader.setErrorHandler( handler );
xmlReader.parse( new InputSource(new StringReader(xml)));
events = (MyEvents)um1.unmarshal(new StringReader(xml));
......
My castor.properties file(relevant ones):
org.exolab.castor.parser=org.apache.xerces.parsers.SAXParser
org.exolab.castor.xml.serializer.factory=org.exolab.castor.xml.XercesXMLSerializerFactory
org.exolab.castor.parser.validation=false
org.exolab.castor.parser.namespaces=false
org.exolab.castor.marshalling.validation=false
org.exolab.castor.sax.features-to-disable=http://apache.org/xml/features/nonvalidating/load-external-dtd
In both the cases, I am getting the same error. The error is during
unmarshalling. Although the parse method returns successfully after
setting the load-external-dtd to false.
Am I missing something?
http://10.72.181.103:8088/comp_server.dtd
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:727)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:588)
at Performance.getEventsUsingXSD(Performance.java:134)
at Performance.main(Performance.java:56)
Caused by: java.io.FileNotFoundException:
http://10.72.181.103:8088/comp_server.dtd
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1131)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown
Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:718)
... 3 more
Caused by: java.io.FileNotFoundException:
http://10.72.181.103:8088/comp_server.dtd
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1131)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown
Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:718)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:588)
at Performance.getEventsUsingXSD(Performance.java:134)
at Performance.main(Performance.java:56)
~Sandeep
On 1/11/07, Werner Guttmann <[EMAIL PROTECTED]> wrote:
Could as well be .. ;-). If you still insist on knowing the truth and
nothing but the truth, src/doc/release-notes.xml is your friend .. ;-).
Werner
Stephen Bash wrote:
> Werner-
>
> Did I ever actually file a bug against this case? I know I thought
> about it, but wasn't sure how far it went... If not, it seems someone
> else complained huh? ;)
>
> Stephen
>
>
> On 1/10/07, Werner Guttmann <[EMAIL PROTECTED]> wrote:
>> Stephen and Sandeep,
>>
>> a few weeks ago (please check the release notes for details), a new
>> property has been added to the castor.propeties file to turn a JAXP/SAX
>> feature off.
>>
>> org.exolab.castor.sax.features-to-disable
>>
>> This might ease your job, I assume .. ;-)
>>
>> Werner
>>
>> Stephen Bash wrote:
>> > Sandeep-
>> >
>> > This echoes back to a problem quite a few months (possibly a year or
>> > two) ago. If you are using the Xerces parser, there is a way to tell
>> > it to ignore that DOCTYPE. As I remember though, you have to create
>> > the parser yourself, configure it correctly and then have Castor use
>> > that parser rather than allowing Castor to create a parser. The
>> > problem stems from Castor only being able to turn ON parser features,
>> > and in this case you actually need to turn OFF a feature.
>> >
>> > For more info, see this old post:
>> >
>> > http://www.mail-archive.com/[email protected]/msg02609.html
>> >
>> > Stephen
>> >
>> >
>> > On 1/10/07, Sandeep <[EMAIL PROTECTED]> wrote:
>> >> Hi
>> >>
>> >> I am working on a project to apply data binding to a legacy xml
>> >> client-server application.
>> >>
>> >> For every xml that my server returns, it has the following header
>> part:
>> >>
>> >> <?xml version='1.0' encoding='UTF-8' ?>
>> >> <!DOCTYPE comp SYSTEM 'http://10.72.181.103:8088/comp_server.dtd'>
>> >> <comp>
>> >> .....
>> >> </comp>
>> >>
>> >> The dtd file comp_server.dtd is non-existent. It was there as part of
>> >> some kind of server's internal logic.
>> >>
>> >> Now, my castor is failing saying unable to locate comp_server.dtd
>> >> which is obvious.
>> >>
>> >> My question is, how can I make castor to ignore that DOCTYPE element.
>> >>
>> >> Currently, I am doing a crude way of String.substring and passing only
>> >> <comp>
>> >> ...
>> >> </comp>
>> >> to castor. But this is a hack!!
>> >>
>> >> ~Sandeep
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list please visit:
>> >>
>> >> http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe from this list please visit:
>> >
>> > http://xircles.codehaus.org/manage_email
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email