users@jaxb.java.net

Re: Need help with JAXB and Office Open XML schemas

From: Jason Harrop <jharrop_at_gmail.com>
Date: Thu, 24 Nov 2011 06:21:40 +1100

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:
>
>
> 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:
>
> 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.
>>
>> <PastedGraphic-2.png>
>>
>>
>> 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-3.png
(image/png attachment: PastedGraphic-3.png)

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