Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Fri, 27 Jun 2008 09:44:49 -0700 (PDT),    group: microsoft.public.dotnet.vjsharp        back       


XMLDocument and java.io.InputStream   
How do I route the contents of an XMLDocument object into a
java.io.InputStream?

XMLDocument exposes two methods called WriteContentTo and WriteTo,
both of which can write to an XML writer.  But, I need the content to
go to a java.io.Input stream so that I can copy it to a
ZipOutputStream.

Andy
date: Fri, 27 Jun 2008 09:44:49 -0700 (PDT)   author:   Andy

Re: XMLDocument and java.io.InputStream   
It doesn't look like anyone visits this group, so I thought I'ld
record what I found out...

I'm trying to write an application that updates the text inside of
a .docx word document, without using Microsoft Word.
Word compresses .docx files through the zip algorithm.  My application
is written in VB.NET 2003 which doesn't have any zip libraries like
those found in VB.NET 2005 or later to decompress/compress files.
But, J Sharp that ships with Visual Studio 2003 does offer zip
functions that can be called from VB.NET programs.

When you decompress a docx file, you will find it contains multiple
files, one of which is the text branch of the word document.  This
file is word\document.xml, and it can be loaded into a xmlDocument DOM
parser.  You can then modify the content of the nodes in this document
and save it back out to the zip file.  Unfortunately, all the zipping
is done through stream copying defined by java.io classes.  The
xmlDocument object doesn't have any methods that allow it to work with
java.io classes.  The xmlDocument object does provide its content in
the form of a string through its outerXML method.  The J Sharp
documentation basically says you have to write your own custom string
streaming class using the StringReader object.

Fortunately, J Sharp 2003 still supports the depreciated
java.io.StringBufferInputStream object.  StringBufferInputStream is
able to stream System.String objects.  But, it can only do this with
regular ascii text and not unicode.  So, as long as the data in the
xmldocument is encoded in UTF-8, the StringBufferInputStream object
should work.

ie  srcStream = New java.io.StringBufferInputStream(docXML.OuterXml)
date: Fri, 27 Jun 2008 11:07:16 -0700 (PDT)   author:   Andy

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us