[SoapRMI] preserving prefixes in document fragments
Aleksander Slominski
aslom_at_cs.indiana.edu
Thu, 15 Feb 2007 17:39:35 -0500
Andy Harrison wrote:
> Hi,
>
> I am doing some work with WordML 2003. I wish to alter the contents of a
> file, modifying only certain elements whilst leaving everything else.
> I'm loading a document as a template and then inserting images and text
> for a report.
>
> I pass over most of the xml... headers, font info, namespaces etc and
> flush that to a BufferedWriter, then I parse the chunks I am interested
> in using builder.parseFragment(XppPullParser xpp).
>
> What I want to know is, is it possible to get the
> builder.serializeToXxxxx functions to not invent their own prefixes and
> use the prefixes that are already loaded??
>
what version of xpp3 did you use? i remember bug like that in past and
it may be fixed in the latest version.
> I've attached an example where I don't change any of the data but the
> serialized output wants to declare its own prefixes. All of the prefixes
> are declared at the top of the file, which I skipped over with
> xpp.next(), so the new xmlns="" declarations are superfluous.
>
> Not that I mind a few extra declarations, but it causes MS Word not to
> show the picture!
>
that sucks - XML should not care about prefixes :-(
best,
alek
>
> ORIGINAL FRAGMENT FROM WORD 2003 ML
>
> myFragment = builder.parseFragment(xpp);
>
> <w:pict>
> <v:shape adj="0,,0" coordsize="" id="_x0_0_180_240.0094" o:spid="_x0000_s1026" o:spt="100" path="" style="stuff">
> <v:stroke joinstyle="round"/>
> <w:binData w:name="wordml://02000001.jpg">base64stuff/9j==</w:binData>
> <v:imagedata o:title="graphics1" src="wordml://02000001.jpg"/>
> <v:formulas/>
> <v:path o:connecttype="segments"/>
> </v:shape>
> </w:pict>
>
>
> A QUICK DUMP OF myFragment
>
> ...the original prefixes are there eg <v:shape o:spid="blah">
>
> /body/sect/p/r/pict {prefix='w',namespaceName='http://schemas.microsoft.com/office/word/2003/wordml'}
> /body/sect/p/r/pict/shape {prefix='v',namespaceName='urn:schemas-microsoft-com:vml'}
> -> id: {prefix='null',namespaceName=''}
> -> spid: {prefix='o',namespaceName='urn:schemas-microsoft-com:office:office'}
> -> style: {prefix='null',namespaceName=''}
> -> coordsize: {prefix='null',namespaceName=''}
> -> spt: {prefix='o',namespaceName='urn:schemas-microsoft-com:office:office'}
> -> adj: {prefix='null',namespaceName=''}
> -> path: {prefix='null',namespaceName=''}
> /body/sect/p/r/pict/shape/stroke {prefix='v',namespaceName='urn:schemas-microsoft-com:vml'}
> -> joinstyle: {prefix='null',namespaceName=''}
> /body/sect/p/r/pict/shape/binData {prefix='w',namespaceName='http://schemas.microsoft.com/office/word/2003/wordml'}
> -> name: {prefix='w',namespaceName='http://schemas.microsoft.com/office/word/2003/wordml'}
> /body/sect/p/r/pict/shape/imagedata {prefix='v',namespaceName='urn:schemas-microsoft-com:vml'}
> -> src: {prefix='null',namespaceName=''}
> -> title: {prefix='o',namespaceName='urn:schemas-microsoft-com:office:office'}
> /body/sect/p/r/pict/shape/formulas {prefix='v',namespaceName='urn:schemas-microsoft-com:vml'}
> /body/sect/p/r/pict/shape/path {prefix='v',namespaceName='urn:schemas-microsoft-com:vml'}
>
>
>
> READ AND THEN RE-SERIALIZE...
>
> builder.serializeToWriter(myFragment,outputWriter);
>
> ...the original prefixes are gone the serializer creates new ones and MS Word doesn't like it
>
> eg. <v:shape n1:spid="blah" xmlns:n1="urn:schemas-microsoft-com:office:office">
>
> <w:pict>
> <v:shape adj="0,,0" coordsize="" id="_x0_0_180_240.0094" n1:spid="_x0000_s1026" n1:spt="100" path="stuff" style="" xmlns:n1="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
> <v:stroke joinstyle="round"/>
> <w:binData w:name="wordml://02000001.jpg">base64stuff/9j==</w:binData>
> <v:imagedata n1:title="graphics1" src="wordml://02000001.jpg"/>
> <v:formulas/>
> <v:path n1:connecttype="segments"/>
> </v:shape>
> </w:pict>
>
--
The best way to predict the future is to invent it - Alan Kay