users@jaxb.java.net

Re: Need help with JAXB and Office Open XML schemas

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 28 Nov 2011 19:07:20 +0100

Tonté,

Sorry for the long delay.

There is no solution for the clash arising from the duplicate inclusion of
an element group, one direct, one indirect.
You'd have to modify the XML schema file by duplicating the group under
another name, so that one each of the
clashing element pairs (there wlll be more than one) can be renamed by
customization. From the XML point of
view, the schema will remain the same.

I simply eliminated on of the group references to see what will happen
next. I ran into another problem, where
JAXB indicates an error but the message is very obscure, and I don't know
how to fix it. But we can tackle this
if you are prepared to proceed as indicated in the previous paragraph.

Cheers
Wolfgang


On 23 November 2011 21:50, Tonté Pouncil <etnot96_at_yahoo.com> wrote:

> Jason,
>
> That would have been my first choice and or Apache POI framework; but
> unfortunately the environment I work in will not allow 3rd party frameworks
> to be used until they have been thoroughly reviewed and officially
> approved. This process could take 6 months or more.
>
> Thanks for the suggestion though!
>
> Tonté
> On Nov 23, 2011, at 1:21 PM, Jason Harrop wrote:
>
> If it is of interest to you, JAXB classes for all these schemas are part
> of docx4j.
> On Thu, Nov 24, 2011 at 3:10 AM, Tonté Pouncil <etnot96_at_yahoo.com> wrote:
>
>> Wolfgang,
>>
>> With your help I was able to resolve my issue. I shrunk my list of
>> schemas down to the following:
>>
>> <PastedGraphic-3.png>
>>
>> I found that the wml.xsd and shared-math.xsd schemas did not reference
>> the correct schema location for the xml.xsd. So I added the correct on
>> thanks to Wolfgang:
>> <PastedGraphic-4.png>
>>
>> And I made sure my working directory is the same directory my schemas are
>> located in.
>>
>> You are correct, I now have to resolve several name collisions.
>>
>> Thanks!
>>
>> Tonté
>>
>> On Nov 23, 2011, at 9:34 AM, Wolfgang Laun wrote:
>>
>> All <xsd:include> reference files via relative pathnames without a
>> directory part. Set your working directory to src/main/resources/xsd and
>> use a suitable path as -d operand.
>> -W
>>
>>
>> On 23 November 2011 16:08, Tonté Pouncil <etnot96_at_yahoo.com> wrote:
>>
>>> Wolfgang,
>>>
>>> Thank you very much for your quick reply. I have done what you
>>> suggested. I have downloaded the xml.xsd, XMLSchema.dtd, and the
>>> datatypes.dtd files. They are located in src/main/resources/xsd folder.
>>> These are the only files in this folder. I run the following xjc
>>> command: xjc -nv -d . src/main/resources/xsd and this is what I get.
>>>
>>>
>>>
>>>
>>> As you can see it did not generate any file in my root directory. Do
>>> you have any suggestion to why I am not able to generate the files? Are
>>> you able to do this on your end?
>>>
>>> At this point all I am trying to do is generate Java objects for the
>>> xml.xsd file and not the Office Open XML Schemas.
>>>
>>> Thanks.
>>>
>>> Tonté
>>> On Nov 23, 2011, at 7:56 AM, Wolfgang Laun wrote:
>>>
>>> You'll need the up-to-date xml.xsd from
>>> http://www.w3.org/2001/03/xml.xsd
>>> and
>>> http://www.w3.org/2001/XMLSchema.dtd
>>> http://www.w3.org/2001/datatypes.dtd
>>>
>>> I prefer to call xjc from the command line, and here strict mode (of the
>>> validation of the XML schemas) is turned off by option "-nv".
>>>
>>> After this, you'll run into some errors due to naming conflicts. They
>>> can be worked around by using customization, as indicated in the error
>>> messages. (Usually, these are due to fundamental incompatibilites between
>>> what can be defined by an XML Schema and a set of Java classes.)
>>>
>>> -W
>>>
>>>
>>>
>>> On 23 November 2011 14:07, Tonté Pouncil <etnot96_at_yahoo.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I've been trying to generate JAXB object from the Open Office XML
>>>> Schemas with no success. The Open Office XML Schemas can be found at the ECMA
>>>> Office Open XML File Formats Standards<http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm> site.
>>>> Once there click on the Download W3C XML Schema files for part 4<http://www.ecma-international.org/news/TC45_current_work/OfficeOpenXML-XMLSchema.zip> link.
>>>> There are about 87 schemas in the zip file. Out of the 87, I am only
>>>> working with 13 of them:
>>>> 1. dml-baseTypes.xsd
>>>> 2. dml-documentProperties.xsd
>>>> 3. dml-graphicalObject.xsd
>>>> 4. dml-shapeGeometry.xsd
>>>> 5. dml-wordprocessingDrawing.xsd
>>>> 6. shared-customXmlSchemaProperties.xs
>>>> 7. shared-math.xsd
>>>> 8. shared-relationshipReference.xsd
>>>> 9. vml-main.xsd
>>>> 10. vml-officeDrawing.xsd
>>>> 11. vml-presentationDrawing.xsd
>>>> 12. vml-spreadsheetDrawing.xsd
>>>> 13. wml.xsd
>>>> 14. xml.xsd - I downloaded this file because above schemas would not
>>>> validate without it. I downloaded it from "
>>>> http://www.w3.org/XML/1998/xml.xsd". I even tried only generating the
>>>> schema for only this xsd but it didn't produce any Java files.
>>>>
>>>> None of these schemas are available through the internet; so I had to
>>>> use a catalog file to resolve the schemas.
>>>>
>>>> Here is what is defined in my catalog file:
>>>> PUBLIC "
>>>> http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
>>>> "xsd/dml-wordprocessingDrawing.xsd"
>>>> PUBLIC "http://schemas.openxmlformats.org/drawingml/2006/main" "xsd/
>>>> dml-graphicalObject.xsd"
>>>> PUBLIC "http://schemas.openxmlformats.org/drawingml/2006/main" "xsd/
>>>> dml-documentProperties.xsd"
>>>>
>>>> I am not for sure if my catalog.cat file is working correctly or not.
>>>>
>>>>
>>>> For some reason JAXB complains that it can't find the type definitions
>>>> that are defined in the include and import files:
>>>>
>>>> [ERROR] Error while parsing schema(s).Location [
>>>> file:/Users/pouncilt/Development/ide/eclipse/eclipse-jee-helios-SR2-macosx-cocoa-x86_64/eclipse_workspace/open-office-xml/src/main/resources/xsd/dml-wordprocessingDrawing.xsd{45,95}].
>>>> org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name
>>>> 'a:CT_NonVisualDrawingProps' to a(n) 'type definition' component.
>>>> at
>>>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>>>>
>>>> The above error goes away if I set the strict mode to "false". Why is
>>>> this the case? Why doesn't it work in when the strict mode is set to
>>>> "true". All of the schemas that I've created work with the strict mode
>>>> set to true.
>>>>
>>>> I also get this following error which is very strange to me because I
>>>> am not referencing the file it is complaining about:
>>>>
>>>> [ERROR] Error while parsing schema(s).Location [
>>>> file:/Users/pouncilt/Development/ide/eclipse/eclipse-jee-helios-SR2-macosx-cocoa-x86_64/eclipse_workspace/open-office-xml/src/main/resources/xsd/dml-wordprocessingDrawing.xsd{489,66}].
>>>> org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name
>>>> 'a:graphic' to a(n) 'element declaration' component.
>>>> at
>>>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>>>>
>>>> I am using maven-jaxb2-plugin. I would be most appreciative if someone
>>>> would download the schemas and try to replicate my problem and tell my how
>>>> to resolve it.
>>>>
>>>>
>>>>
>>>> Thank you in advance.
>>>>
>>>> Tonté Pouncil
>>>>
>>>
>>>
>>>
>>
>>
>
>




PastedGraphic-6.png
(image/png attachment: PastedGraphic-6.png)