在JIBX中绑定 [英] Binding in JIBX

查看:299
本文介绍了在JIBX中绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我刚刚开始使用JIBX,但是我很难掌握Binding概念.我已经从XSD文件生成了JAVA类 我正在使用Windows,这是我的文件夹的结构

Hi I just started using JIBX and I am having difficulty grasping the Binding concept. I have generated the JAVA classes from an XSD File I am using windows and here is how my folders are structures

d:\ Libraries \ 该文件夹包含下载的jibx文件夹,因此rar库(例如jibx-tools.jar)位于 d:\ Libraries \ jibx \ lib .....

d:\Libraries\ This folder contains the jibx folder downloaded so the rar libraries like jibx-tools.jar are in d:\Libraries\jibx\lib.....

现在,Libraries文件夹中还包含一个名为dwcode2的文件夹 我在其中有一个名为starter.xsd的XSD文件 D:\ Libraries \ jibx \ dwcode2 \

Now the Libraries folder also contains a folder called dwcode2 I have an XSD File called starter.xsd in D:\Libraries\jibx\dwcode2\

我在DOS中使用命令生成了JAVA文件 D:\ Libraries \ jibx \ dwcode2> java -cp .. \ lib \ jibx-tools.jar org.jibx.schema.codegen.CodeGen -t gen \ src -w starter.xsd

I generated the JAVA files using the command in DOS D:\Libraries\jibx\dwcode2>java -cp ..\lib\jibx-tools.jar org.jibx.schema.codegen.CodeGen -t gen\src -w starter.xsd

结果是在以下位置生成了JAVA文件: D:\ Libraries \ jibx \ dwcode2 \ gen \ src \ org \ jibx \

as a result JAVA files were generated in D:\Libraries\jibx\dwcode2\gen\src\org\jibx\

并在其中生成binding.xml D:\ Libraries \ jibx \ dwcode2 \ gen \ src

and the binding.xml was generated in D:\Libraries\jibx\dwcode2\gen\src

现在我要编译并绑定文件(有人可以告诉我为什么我们必须编译并绑定XML) 所以我做了以下 D:\ Libraries \ jibx \ dwcode2 \ gen \ src> java -jar"D:\ Java Libraries" \ jibx \ lib \ jibx-bind.jar binding.xml

Now I want to compile and bind the file (Could anyone also tell me why do we have to compile and bind the XML ) So i did the following D:\Libraries\jibx\dwcode2\gen\src>java -jar "D:\Java Libraries"\jibx\lib\jibx-bind.jar binding.xml

Error: Unable to find type org.jibx.starter.Shipping; on format element at (line 3, col 66, in binding.xml)Error: Cannot find information for class org.jibx.starter.Item; on mapping element at (line 4, col 79, in binding.xml)Error: Cannot find information for class org.jibx.starter.Address; on mapping element at (line 9, col 85, in binding.xml) Error: Cannot find information for class org.jibx.starter.Customer; on mapping element at (line 17, col 87, in binding.xml)Error: Cannot find information for class org.jibx.starter.Order; on mapping element at (line 22, col 81, in binding.xml) Error: Cannot find information for class org.jibx.starter.Order; on mapping element at (line 35, col 56, in binding.xml) Error running binding compiler org.jibx.runtime.JiBXException: Binding binding.xml is unusable because of validation errors at org.jibx.binding.Utility.loadBinding(Utility.java:358)   at org.jibx.binding.Utility.loadFileBinding(Utility.java:420)
                    at org.jibx.binding.Compile.compile(Compile.java:217)
                    at org.jibx.binding.Compile.main(Compile.java:384)

任何人都可以告诉我我做错了什么吗?我该如何解决这个问题?以及为什么我们必须绑定??

Could anyone please tell me what i am doing wrong ?? How can i fix this problem ? and why do we have to bind ??

推荐答案

Rajesh,

使用JiBX代码生成器时,需要执行三个步骤:
1.使用代码生成器从XML模式生成Java代码和绑定文件
2.编译您的Java代码
3.使用绑定编译器修改Java类文件,以便它们可以生成XML模式.
我看不到您的架构,所以为什么不进行测试以查看问题是您的架构还是您的命令行:
-将您的架构放在一个空目录中并运行这些命令.

When you use the JiBX code generator, you need to do three steps:
1. Use the code generator to generate java code and a binding file from XML schema
2. Compile your java code
3. Use the binding compiler to modify your java class files so they can generate XML schema.
I can't see your schema, so why don't you do a test to see if the problem is your schema or your command lines:
- Place your schema in an empty directory and run these commands.

java -cp ../lib/jibx-tools.jar org.jibx.schema.codegen.CodeGen starter.xsd
javac -cp ../lib/jibx-run.jar:. org/jibx/starter/Shipping.java
java -cp ../lib/jibx-bind.jar:. org.jibx.binding.Compile binding.xml

当然,您将用您的路径(即c:\ Library)替换lib目录的路径.

Of course your will replace the path to the lib directory with your path (ie., c:\Library).

如果可行,现在您可以将项目组织到文件夹中.

If this works, now you can organize your project into folders.

您可以在我们的网站上找到完整的文档,网址为 www.jibx.org .

You can find complete documentation on our site at www.jibx.org.

要真正简化您的生活,我建议您使用maven插件.配置要容易得多.

To really simplify your life, I would recommend using the maven plugin. Configuration is much easier.

我希望这会有所帮助.

这篇关于在JIBX中绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆