Page 1 of 1

[docProps] - create a valid coreproperties - JAXB - cdterms

PostPosted: Wed Feb 05, 2014 6:00 am
by marcel_cap
Hello,

I would like to create a coreProperties.
All is ok, unlike for the two elements : dcterms:created / dcterms:modified.

What I obtains is :
Code: Select all
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <cp:category>category</cp:category>
   <cp:contentStatus>contentStatus</cp:contentStatus>
   <cp:contentType>contentType</cp:contentType>
   <dc:creator>creator</dc:creator>
   <dc:description>description</dc:description>
   <dc:identifier>identifier</dc:identifier>
   <cp:keywords>keywords</cp:keywords>
   <dc:language>language</dc:language>
   <cp:lastModifiedBy>lastModifiedBy</cp:lastModifiedBy>
   <cp:lastPrinted>2011-09-29T08:55:00Z</cp:lastPrinted>
   <cp:revision>1</cp:revision>
   <dc:subject>subject</dc:subject>
   <dc:title>title</dc:title>
   <cp:version>version</cp:version>
   <dcterms:created>2014-02-04T16:25:00Z</dcterms:created>
   <dcterms:modified>2014-02-04T16:26:00Z</dcterms:modified>
</cp:coreProperties>


You see that there are note conform with the xsd, actually I have to have :
Code: Select all
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <cp:category>category</cp:category>
   <cp:contentStatus>contentStatus</cp:contentStatus>
   <cp:contentType>contentType</cp:contentType>
   <dc:creator>creator</dc:creator>
   <dc:description>description</dc:description>
   <dc:identifier>identifier</dc:identifier>
   <cp:keywords>keywords</cp:keywords>
   <dc:language>language</dc:language>
   <cp:lastModifiedBy>lastModifiedBy</cp:lastModifiedBy>
   <cp:lastPrinted>2011-09-29T08:55:00Z</cp:lastPrinted>
   <cp:revision>1</cp:revision>
   <dc:subject>subject</dc:subject>
   <dc:title>title</dc:title>
   <cp:version>version</cp:version>
   <dcterms:created xsi:type="dcterms:W3CDTF">2014-02-04T16:25:00Z</dcterms:created>
   <dcterms:modified xsi:type="dcterms:W3CDTF">2014-02-04T16:26:00Z</dcterms:modified>
</cp:coreProperties>


My code :
Code: Select all
    org.docx4j.docProps.core.ObjectFactory factoryCore = new org.docx4j.docProps.core.ObjectFactory();
    CoreProperties coreProps = factoryCore.createCoreProperties();
            org.docx4j.docProps.core.dc.terms.ObjectFactory factoryDcTerms = new org.docx4j.docProps.core.dc.terms.ObjectFactory();
            W3CDTF term = factoryDcTerms.createW3CDTF();
            jsl = factoryDcTerms.createCreated(term);

            term.getContent().add(valeurCourante);

            coreProps.setCreated(term);


Do you have any idea why the type of the element is not set ?




Thanks

Re: [docProps] - create a valid coreproperties - JAXB - cdte

PostPosted: Thu Feb 06, 2014 11:58 pm
by marcel_cap
To resolv the pb I have used the XMLUtil from docx4J

Code: Select all
    org.docx4j.docProps.core.CoreProperties coreProps;
    coreProps = getCoreProp();
    String corePropString= org.docx4j.XmlUtils.marshaltoString(coreProps, false, true, Context.jcDocPropsCore);