Click to See Complete Forum and Search --> : uploading & processing a xml file


crojar
September 16th, 2003, 01:01 PM
Ok this might be a stoopid question, but here I go. I have a html that will upload and process an xml string successfully.

html code that works:

<FORM action="http://xxx.xxx.com/xxx/dispatcher" method=post>
<INPUT TYPE=text size=220 name=com.xxx.xxx.xxx.REQUEST_PLACEHOLDER value="<!DOCTY....

However, I want to upload and process an xml file to the same server. I tried 3 different ways: curl, html form, and vba

Each way I connect to the server but the requrest is not successful

1) C:\temp\curl>curl -d@auth_simple_rqstII.xml -o myresp.xml "http://xxx.xxx.com/xxx/dispatcher"

server log:

[Fatal Error] :1:1: Premature end of file.
org.xml.sax.SAXParseException: Premature end of file.


2) Html Form

<form enctype="multipart/form-data" method="post" action="http://xxx.xxx.com/xxx/dispatcher">
Enter filename to upload: <input type="file" name="xxx.xxx.xxx.xxx.REQUEST_PLACEHOLDER"><br>
<input type="submit">

server log

[Fatal Error] :1:1: Content is not allowed in prolog.
org.xml.sax.SAXParseException: Content is not allowed in prolog.

3) VBA request

server log: [Fatal Error] :1:1: Premature end of file.
org.xml.sax.SAXParseException: Premature end of file.


Do I need to modify the xml file ( I can load it in sucessfully in MS XML notepad)?

Do I need to change the HTTP request?

rabin0421
June 1st, 2005, 10:20 PM
Does anyone has any idea about this problem. I runs into the same situation.

Krzemo
June 2nd, 2005, 04:46 AM
I'm not a web developer ... but concerning error description "org.xml.sax.SAXParseException: Content is not allowed in prolog" I can guess that feedback from HTTP request is enclosed in HTML envelope (it seams to be logical since it is HTML request :rolleyes: ). So before U start processing XML U should somehow strip of that envelope.



Best regards,
Krzemo.

zuluTheCoder
July 17th, 2006, 09:08 PM
hi I do not know if this thread but I would love for somebody to look at the following:
( for those of you who want to actually try the code, it can be downloaded at http://www.people.virginia.edu/~gsd4x/DigitalLibrary.zip)
here is the xml file:

<?xml version = "1.0" encoding= "UTF-8"?>
<library>
<item>
<type>
1
</type>
<id>
266
</id>
<author>
authors_name
</author>
<title>
item's title
</title>
<date>
MONTH/DAY/YEAR
</date>
<issue>
235
</issue>
<edition>
2nd_Edition
</edition>
<publisher>
Computer_Arts
</publisher>
<keyword>
KEY WORD
</keyword>
<description>

</description>
</item>
</library>


and here is the code to process it:

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
try {
SAXParser parser = factory.newSAXParser();
parser.parse( new File(libraryfile), libHandler );
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
} catch (SAXException ex) {
ex.printStackTrace();
}


I get the same type of error mentioned:

init:
deps-jar:
Compiling 4 source files to E:\programming\G_java\DigitalLibrary\DigitalLibrary\build\classes
compile:
run:
org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:230)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:311)
at Library.<init>(Library.java:55)
at EntryForm.<init>(EntryForm.java:18)
at EntryForm$7.run(EntryForm.java:555)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
BUILD SUCCESSFUL (total time: 11 seconds)


thanks in advance

jkmyoung
July 18th, 2006, 10:55 AM
Sounds like your xml is not well formed, or the parser is overparticular.
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:230)

Try removing the spaces:
Change <?xml version = "1.0" encoding= "UTF-8"?>
to
<?xml version="1.0" encoding="UTF-8"?>

zuluTheCoder
July 19th, 2006, 07:37 PM
I have tried it and I still get the same answer.

jkmyoung
July 20th, 2006, 10:34 AM
1. You need a space between item and ( in lib.dtd
2. Have you tried using the DefaultHandler class as opposed to your LibraryHandler? Do you still get the same parsing errors?

zuluTheCoder
July 21st, 2006, 06:59 PM
I have tried it and I still get the same error