Page 1 of 1

[ERROR] : unexpected element (uri:"http://schemas.microsoft.

PostPosted: Fri Aug 02, 2013 11:18 am
by ikola
Hi Jason,

Is there a fix for the below issue. If so can you please provide the version of jar with those changes.

Need to check/uncheck the check box using 2010 docx template and currently getting below error .

[ERROR] : unexpected element (uri:"http://schemas.microsoft.com/office/word/2010/wordml", local:"checkbox"). Expected elements are
- continuing (with possible element/attribute loss)

Thank you for the support.

Regards,
Isaac

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Fri Aug 02, 2013 11:44 am
by jason
Nightly builds from July 10 support 2010 checkbox. The most recent is currently http://www.docx4java.org/docx4j/docx4j- ... 130721.zip but I will probably publish another today.

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Fri Aug 09, 2013 8:58 am
by ikola
Hi Jason,

Is it possible to provide the 2010 Check Box content control fix with 2.8.1 release jar ?

Thank you for the support and help.

Regards,
Isaac

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Fri Aug 09, 2013 1:31 pm
by jason
Hello Issac

It would be possible, but not straightforward.

Better if possible to use a nightly build, or wait for 3.0

cheers .. Jason

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Sat Aug 10, 2013 9:21 am
by ikola
Thank you for the support and cool stuff.

May I know when is 3.0 release ?

Planning to include this in next sprint and if you can provide patch on 2.8.1 that will be really helpful.

Regards,
Isaac

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Tue Aug 13, 2013 10:11 pm
by jason
ikola wrote:May I know when is 3.0 release ?


Hi Isaac, hopefully within the next month or so. We've been a bit relaxed about releasing it, since the 2.8.1 point releases have taken most of the pressure off.

ikola wrote:Planning to include this in next sprint and if you can provide patch on 2.8.1 that will be really helpful.


I don't think it makes much sense to backport this key 3.0 feature to 2.8.1, given that it touches a lot of files and 3.0 is close. Sorry about that.

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Tue Nov 19, 2013 8:40 pm
by thapliyal.kshitiz
Hi Jason,

Is checking/uncheking a checkbox included in 3.0 beta version?

If yes, how to do that ?

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Wed Nov 20, 2013 8:12 pm
by jason
Hi, yes it is.

The XML will look something like:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
    <w:sdt>
      <w:sdtPr>
        <w:id w:val="824551180"/>
        <w14:checkbox>
          <w14:checked w14:val="0"/>
          <w14:checkedState w14:val="2612" w14:font="MS Gothic"/>
          <w14:uncheckedState w14:val="2610" w14:font="MS Gothic"/>
        </w14:checkbox>
      </w:sdtPr>
      <w:sdtContent>
        <w:p w:rsidR="008A6B02" w:rsidRDefault="00FE5E91">
          <w:r>
            <w:rPr>
              <w:rFonts w:ascii="MS Gothic" w:eastAsia="MS Gothic" w:hAnsi="MS Gothic" w:hint="eastAsia"/>
            </w:rPr>
            <w:t></w:t>
          </w:r>
        </w:p>
      </w:sdtContent>
    </w:sdt>
 
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


w14:checkbox is represented by org.docx4j.w14.CTSdtCheckbox

Assuming you have SdtPr sdtPr, you'll find it in here (probably wrapped in JAXBElement):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                                        for (Object o2 : sdtPr.getRPrOrAliasOrLock()) {
                                                o2 = XmlUtils.unwrap(o2);
                                                System.out.println(o2.getClass().getName());
                                        }
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Thu Nov 21, 2013 12:53 am
by thapliyal.kshitiz
Below is my document:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
- <w:body>
- <w:p w:rsidR="00A7711F" w:rsidRDefault="00190296">
- <w:r w:rsidRPr="00907425">
- <w:rPr>
<w:b />
</w:rPr>
- <w:fldChar w:fldCharType="begin">
- <w:ffData>
<w:name w:val="" />
<w:enabled />
<w:calcOnExit w:val="0" />
- <w:checkBox>
<w:size w:val="18" />
<w:default w:val="0" />
<w:checked w:val="0" />
</w:checkBox>
</w:ffData>
</w:fldChar>
</w:r>
- <w:r w:rsidRPr="00907425">
+ <w:rPr>
<w:b />
</w:rPr>
<w:instrText xml:space="preserve">FORMCHECKBOX</w:instrText>
</w:r>
- <w:r>
- <w:rPr>
<w:b />
</w:rPr>
</w:r>
+ <w:r>
- <w:rPr>
<w:b />
</w:rPr>
<w:fldChar w:fldCharType="separate" />
</w:r>
- <w:r w:rsidRPr="00907425">
- <w:rPr>
<w:b />
</w:rPr>
<w:fldChar w:fldCharType="end" />
</w:r>
- <w:r>
- <w:rPr>
<w:b />
</w:rPr>
<w:t xml:space="preserve">My name is kshitiz</w:t>
</w:r>
</w:p>
- <w:sectPr w:rsidR="00A7711F" w:rsidSect="00764431">
<w:pgSz w:w="12240" w:h="15840" />
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0" />
<w:cols w:space="720" />
<w:docGrid w:linePitch="360" />
</w:sectPr>
</w:body>
</w:document>

What to do for this structure?

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Thu Nov 21, 2013 8:32 am
by jason
That's a legacy FORMCHECKBOX - a completely different beast.

To see how it is represented in docx4j, you can upload your docx to the webapp (linked in menu above).

docx4j's higher level code for manipulating fields is in https://github.com/plutext/docx4j/tree/ ... del/fields

FieldRef contains:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        /**
         * Properties specific to FORMCHECKBOX, FORMDROPDOWN, FORMTEXT
         *
         * @return the formFieldProperties
         * @see <a href="http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ffData.html">the spec</a>
         */

        public CTFFData getFormFieldProperties() {
                return formFieldProperties;
        }
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


and there is a corresponding setter.

If you want to try using this, you'll probably need to study the source code.

Bear in mind that the spec provides for simple and complex fields. The strategy in that package is to convert simple fields to complex ones, so it can focus on manipulating complex fields only.

Re: [ERROR] : unexpected element (uri:"http://schemas.micros

PostPosted: Thu Nov 21, 2013 9:36 pm
by thapliyal.kshitiz
What shall be passed in fldCharBegin?

public FieldRef(FldChar fldCharBegin) {
this.fldCharBegin = fldCharBegin;
}

as FieldRef constructor needs an argument of type fieldRef :)