Re: [bdbxml] XMLInputStreams and regular InputStreams and w3c DOM objects.
Moe <[email protected]> Mon, 26 Sep 2005 18:18:26 +0000 (UTC)
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
John Snelson <jsnelson@...> writes:
(...)
> The only way to acheive this presently is to stream the data from a
> file, using XmlManager.createLocalFileInputStream().
I would definitely give that a try, but I don't seem to get the file streaming
working at all.
Let's take a look into the Java Getting Started Guide, there's a little example
regarding XmlInputStream:
-----------------------------
String file1 = "doc1.xml";
XmlTransaction txn = myManager.createTransaction();
try {
// Need an update context for the put.
XmlUpdateContext theContext = myManager.createUpdateContext();
// Get the first input stream.
XmlInputStream theStream =
myManager.createLocalFileInputStream(file1);
// Put the first document
myContainer.putDocument(txn, // the transaction object
file1, // The document's name
theStream, // The actual document.
theContext, // The update context
// (required).
0); // Put flags.
-----------------------------
Now my test code looks like this:
------------------
String xmlfileorigin="I:/streamtest/xml/temp.data";
File checkfile = new File (xmlfileorigin);
if (checkfile.exists()){
System.out.println("File's available");
XmlUpdateContext theContext = theMgr.createUpdateContext();
XmlInputStream theStream=theMgr.createLocalFileInputStream(xmlfileorigin);
openedContainer.putDocument("temp.xml", theStream,theContext, 0);}
else {System.out.println("File does not exist, task aborted");}
------------------
The question is, where's the difference, because my version ain't working? I've
set setAllowExternalAccess(true) for the XmlManager, but all I get is:
"The resource does not exist: malformed or non-existent stream source, errcode =
INVALID_VALUE"
What does malformed in this context mean? The file does exist and the content
looks like this:
<?xml version="1.0" ?><data><id>1</id><content>random content</content></data>
Does the error occur due to the design of the xml file content?
Help deeply appreciated.
Regards,
M.B.
------------------------------------------
To remove yourself from this list, send an
email to [email protected]