Here is the prior email I had sent to the thread a week or so ago that explains it.
Basically, I want to "solve" the large document problem by using the FilterXmlObject that will replace a node in the tree and override its save() and load() methods to save and load from disk instead of to memory. Since I know that the data in these nodes is not XML, it's TEXT data, this shouldn't cause problems for my schema. I'll take a look at the SVN stuff but I don't see any publicly available interfaces for taking a cursor or a document object and replacing a node in it with my FilterXmlObject. Basically, I want to do this: Document fooDoc = FooDoc.Factory.newDocument(); Bar bar = fooDoc.addNewBar(); FilterXmlObject wrapper = new MyWrapperObj(bar); fooDoc.replaceNode(bar, wrapper); fooDoc.save(); //This will call the save() method in my filter which will know to read from disk and write to the save()s output stream. Thanks, cory -----Original Message----- From: Cory Virok [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 10:31 AM To: [email protected] Subject: RE: Using Custom XmlObject This was also asked for back in Jun 2006, although I don't think Brian was using a FilterXmlObject... maybe just a custom serializer. http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200606.mbox/%3c99479F4 [EMAIL PROTECTED] Was there ever anything done in this area? Thanks, cory -----Original Message----- From: Cory Virok [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 9:37 AM To: [email protected] Subject: Using Custom XmlObject I have a somewhat simple problem and I am 90% of the way there with the solution. Problem: I have an XML document that I create on the fly but I have *very* large text segments for some of the nodes. I want to be able to create the document via the strongly typed schema-generated classes from scomp and then be able to hook into the serialization of the XML tree so that when the serialization gets to a particular node in the tree, it will read from an input stream that contains my large amount of data and pipe it to the output stream that I gave to save(). I figured that instead of writing my own serializer/tree walker, I would just try and use a custom XmlObject implementation. Currently, I have something that extends FilterXmlObject and is hooking into the save(*) methods. So, if I call save(*) on it, the input stream gets read and piped to the output stream given to save(*). My problem is... I can't get the FilterXmlObject into the document! I see lots of documentation about using FilterXmlObject but I haven't found *any* examples of how to get it into the tree. Here's some code for all that just skipped the long verbage: (just the relevant bits) public class PayloadInjector extends FilterXmlObject { private final XmlObject innerXmlObj; private transient InputStream ins; public PayloadInjector(XmlObject obj) { if(obj == null) { throw new NullPointerException(); } this.innerXmlObj = obj; } @Override public XmlObject underlyingXmlObject() { return innerXmlObj; } @Override public void save(OutputStream os, XmlOptions options) throws IOException { BufferedReader bin = new BufferedReader(new InputStreamReader(ins)); String line; while((line = bin.readLine()) != null) { os.write(line.getBytes()); } } public void setInputStream(InputStream ins) { if(ins == null) { throw new NullPointerException(); } this.ins = ins; } } ================ @Override protected void setUp() throws Exception { doc = FooDocument.Factory.newInstance(defaultOpts); Foo foo = doc.addNewFoo(); pref = foo.addNewPreference(); pref.setStringValue("REPLACE ME!"); injectBuilder = new StringBuilder("YAY!, you injected some data!"); ins = new java.io.ByteArrayInputStream(injectBuilder.toString().getBytes("UTF-8")); } public void testSaveOutputStreamXmlOptions() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PayloadInjector pi = new PayloadInjector(pref); pi.setInputStream(ins); /* !!!!!!!!!!!!!!!!!!!!!!!!!! * How do I get this node into doc?? * !!!!!!!!!!!!!!!!!!!!!!!!!! */ try { doc.save(baos); // visually look for } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } System.out.println(baos.toString()); } All help is appreciated. Thanks, cory --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

