Page 1 of 1

What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Jul 24, 2013 3:44 am
by tinne
Checks about what OpenDoPEHandler now does on conditional removing (either negative condition or zero occurrances) are only partly promising. I ran the processor on the attached
Schablone.docx
template file
(36.56 KiB) Downloaded 394 times
producing defective attachment
Resultat.docx
result file
(28.44 KiB) Downloaded 393 times
After fixing by Word 2010, the following shows:

Positive:
  • Simple paragraphs are successfully removed ("Text")
  • Simple text is successfully removed ("mit Inline-Inhalten")
  • Table rows are successfully removed ("Zeile")
  • Table cells are successfully removed ("Zelle")
  • Lines in table cells are successfully removed ("Absatz in Zelle")
  • In-line text in table cells is successfully removed ("inline")
Negative:
  • Complete tables are replaced by a single cell table ("komplette Tabelle") without a paragraph (thus the defect)

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Jul 24, 2013 8:50 pm
by tinne
The complete table issue is partially a Word resp. OpenDoPE-plugin issue, as the data structure of a bound table depends on its size:
  • When I add a condition (or repeat, appearantly interchangeably) to a table with at least two rows, the structure created is correct:
    Code: Select all
    sdt > sdtContent > tbl > tr > tc > p > r > t
  • When I add a condition to a table with one row, the structure is incorrectly created as
    Code: Select all
    tbl > sdt > sdtContent > tr > tc > p > r > t
    , though this can be mended manually and is then tolerated by Word
  • When the table with one row also only contains one table, the structure is transformed to
    Code: Select all
    tbl > tr > tc >  sdt > sdtContent > p > r > t
    and this structure is re-created by Word on every safe.

The attachments contain additional examples of this.

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Thu Jul 25, 2013 4:11 am
by tinne
The issue can be fixed by an improvement to RemovalHandler, cf. https://github.com/plutext/docx4j/pull/77

This pull request also addresses the topic of empty SDTs: When a plain text is bound to some XPath which after some transformation points to an empty or void element (<empty/> or <void attributes="nevermind"></void>), Word prompts for those elements to ask the user to add some text "click here to add..."
In automatically generated tests, this can be disturbing. The new key parameter "empty" to RemovalHandler.removeSDTs thus removes only xpath elements which no longer references a valid CustomXML target.

This can be validated on the attached sample documents.

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Sun Jul 28, 2013 1:29 pm
by jason
I ran the Schablone documents through https://github.com/plutext/docx4j/blob/ ... sions.java

I was unable to reproduce your observations.

Perhaps you are missing the step:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
                odi.process(wordMLPackage);
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


which is responsible for handling cases like this?

I have partially reverted pull/77

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Thu Aug 01, 2013 12:18 pm
by jason
Hi Tinne

It turns out some table amelioration can be also required at this step, owing to removal of sdt.

https://github.com/plutext/docx4j/commi ... 3a48d33166 does this.

Could you please verify it addresses your use cases?

thanks .. Jason

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Dec 18, 2013 9:17 pm
by handke
I just checked out the latest docx4j library (3.0.0) and checked the above mentioned behaviour. I added the recommanded lines

Code: Select all

OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(wordMLPackage);


after the Preprocessiong of the document. Unfortunately I still get "Pleas enter Code here" for cells which have been replaced with empty content. I attached a sample template, a custom XML with an empty cell1 and the result.

Currently we are working with a patched Version of docx4j based on the Pull-Request by tinne (https://github.com/plutext/docx4j/pull/77). But I'd rather would like to switch to the offical version.

Do you have any ideas what is going wrong?

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Dec 18, 2013 9:34 pm
by handke
I did run the template and the custom XML through the testclass (https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlBindingExtensions.java) you mentioned before.

I still get the problem with a empty cell in the table.

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Dec 18, 2013 10:18 pm
by jason

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Wed Dec 18, 2013 11:51 pm
by handke
Thank you very much. That works for me.

As skiwi suggests it might be a good idead to pull configurations like this out of the jar into a some kind of configfile.

Re: What remained when removeSdtCellsOnFailedCondition went

PostPosted: Tue Jan 07, 2014 1:37 am
by handke
Hi Jason,

unfortunately I have another issue I am currently not able to solve.

What we want to do is to make cells of a table dependent on a condition. If the condition is met the cell should be rendered otherwise it should not be rendered. I attached an example template with a table. The second cell of the first row is bound to a condition. With the attached custom.xml the condition is not met an therefore I expected the cell not to be rendered. As you can see in the attached resulting document only the content is not rendered but the cell is.

It did work with the patched Version of docx4j based on the Pull-Request by tinne (https://github.com/plutext/docx4j/pull/77). With this version the cell is not rendered.

Do you have any ideas what I can do to render or delete cells based on conditions?

Theank you very much for your help.