Page 1 of 1

No excel chart names transferred

PostPosted: Tue May 15, 2012 7:54 pm
by Binko
HI all,

I used docx4 to copy some docm templates. There are embedded excel charts in the templates. I use their names to identify them later and fill them with data.
But docxj4 do not actually transfer their names.

It transfers their descriptions however, and I could get around this problem.
But it is still better than one uses chart names to identify them and not chart decsriptions.

Re: No excel chart names transferred

PostPosted: Tue May 15, 2012 11:33 pm
by jason
docx4j exposes what is in the docm, nothing more and generally speaking, nothing less.

Could you please pinpoint exactly where the name you mention appears in the docm?

In the main document part document.xml, the reference to the chart is by relId, for example:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId5"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


though I see there also <wp:docPr id="1" name="Chart 1"/>. Does that correspond to your name?

You'd think that a name could appear in the chart part itself, but I didn't notice it in the example I looked at.

Re: No excel chart names transferred

PostPosted: Wed May 16, 2012 1:55 am
by Binko
I am sorry, it is not the name, it is the title

in the original docm

<wp:docPr id="53" name="Diagramm 53" descr="LoadShareOverTotalOperatingHours" title="LoadShareOverTotalOperatingHours" />

It is in the docPr but as it seems, it is not parsed.

This is the copied through docxj

<wp:docPr id="53" name="Diagramm 53" descr="LoadShareOverTotalOperatingHours" />

The title is missing.

I am using docx4j-2.7.1

It is just funny that the description is transferred and not the title.

Re: No excel chart names transferred

PostPosted: Wed May 16, 2012 1:58 am
by Binko
So , the problem is actually with parsing the document.xml

There were also not methods for the title. It is just an omission, but still could be corrected.

Re: No excel chart names transferred

PostPosted: Fri May 18, 2012 3:57 pm
by jason
It looks like there may be a problem with the schema.

We have

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<wp:docPr id="53" name="Diagramm 53" descr="LoadShareOverTotalOperatingHours" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


where wp is "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"

The schema https://github.com/plutext/docx4j/blob/ ... rawing.xsd contains:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
        <xsd:import schemaLocation="dml-documentProperties.xsd"
                namespace="http://schemas.openxmlformats.org/drawingml/2006/main" />
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


There is a discrepancy between namespaces here which needs to be investigated. I've created an issue for this on GitHub, see https://github.com/plutext/docx4j/issues/1

Re: No excel chart names transferred

PostPosted: Sat May 19, 2012 10:36 am
by jason
Interestingly, roundtripping a file, IN:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                  <wp:docPr id="54" name="Diagramm 54"
                           descr="desc1"
                           title="title1"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


becomes OUT:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                  <wp:docPr descr="desc1"
                           name="Diagramm 54" id="54"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


so the element is correctly written to the correct namespace, but @title is lost. org.docx4j.dml.wordprocessingDrawing.Inline contains field org.docx4j.dml.CTNonVisualDrawingProps docPr, which doesn't contain a title field, which explains that.

But it is not clear to me how JAXB manages to get the namespace right? I though xsd:import kept the element in its original namespace (ie drawingml/2006/main) as opposed to moving it to wp:. If that's correct, how does JAXB know what to do when it encounters this element in the wp namespace? Looks like it is just happily assuming that namespace, since the reference is from there, and there is no field annotation which tells it to use a different namespace. (So, did xjc do the right thing in writing this element without a field annotation, or not?)

Re: No excel chart names transferred

PostPosted: Sat May 19, 2012 8:32 pm
by Binko
Yes, I would like to investigate that too.