Page 1 of 1

how can i get content from "settings.xml" and "webSettings"

PostPosted: Sun Oct 25, 2009 4:19 am
by eric
Code: Select all
DocumentSettingsPart setting = wordMLPackage.getMainDocumentPart().getDocumentSettingsPart();


i try to get DocumentSettingsPart ,but it return null,then i found that there is't set value to documentSettingsPart in "DocumentPart.java" .is the part "settings.xml" not finished yet?

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Sun Oct 25, 2009 12:31 pm
by jason
Hi Eric

I think all that was missing is the change in http://dev.plutext.org/trac/docx4j/changeset/944

Until there is a jar incorporating that change, you can get the DocumentSettingsPart from the MainDocumentPart's relationships, using something like:
Code: Select all
Relationship r = mdp.getRelationshipsPart().getRelationshipByType(type);
DocumentSettingsPart dsp = mdp.getRelationshipsPart().getPart(r);


cheers .. Jason

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Mon Oct 26, 2009 4:10 am
by eric
Code: Select all
Relationship r = mdp.getRelationshipsPart().getRelationshipByType(Namespaces.SETTINGS);
DocumentSettingsPart dsp = (DocumentSettingsPart)mdp.getRelationshipsPart().getPart(r);


i use this method to get DocumentSettingsPart ,but when i invoke dsp..getJaxbElement() ,try to get CTSettings ,it return wrong value;the type remain JaxbElement.

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Mon Oct 26, 2009 6:40 am
by jason
Annoying that it unmarshalls as that.

I've committed a minor change that essentially returns ((JAXBElement)jaxbElement).getValue();

You'll still need to cast to CTSettings.

Without using the new code, you could in your own code do something like:
Code: Select all
(CTSettings)((JAXBElement)jaxbElement).getValue();


cheers .. Jason

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Mon Oct 26, 2009 10:19 am
by eric
cau you upload a nightly version please?i can't compile my app,thanks

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Mon Oct 26, 2009 11:55 am
by jason
eric wrote:cau you upload a nightly version please?i can't compile my app,thanks


Not right now; I'm in the middle of some changes. Hopefully in a few hours ...

Re: how can i get content from "settings.xml" and "webSettings"

PostPosted: Mon Oct 26, 2009 2:57 pm
by jason
Hi Eric

You can try http://dev.plutext.org/docx4j/docx4j-ni ... 091026.jar

Remember, a nightly is not intended for production usage.

cheers .. Jason