I would like to create XML Documents from XSD files on GWT-based server. Unfortunately I can't use the javax.xml.bind package, the compiler gives me the following error:
我想在基于GWT的服务器上从XSD文件创建XML文档。不幸的是我不能使用javax.xml.bind包,编译器给我以下错误:
No source code is available for type javax.xml.bind.Marshaller; did you forget to inherit a required module?
I tried alternative libraries but they use the Marshaller or JAXBContext from the above package Parse XML file in GWT server-side. GWT's XML Parser doesn't work on the server side. Overriding the package implementation didn't work either. In addition I would like to validate XML files with the schema.
我尝试了替代库,但他们使用GWT服务器端上面的Parse XML文件包中的Marshaller或JAXBContext。 GWT的XML Parser在服务器端不起作用。覆盖包实现也不起作用。另外,我想用模式验证XML文件。
Edit solution:
I referred to the given solution and the links in my initial question. I couldn't get the JAXB-stuff to work on the client side, because there were too many dependencies and I don't like to add all source files in a new package. Nevertheless I can use the xml annotations in shared code. Due to the amount of explanations, their confusing style (my opinion) and the current year, I will explain my approach. It is the same as in other solutions, maybe a little bit easier to understand and totally based on Tassos Bassoukos from the accepted solution:
我在最初的问题中提到了给定的解决方案和链接。我无法让JAXB的东西在客户端工作,因为有太多的依赖项,我不喜欢在新的包中添加所有源文件。不过我可以在共享代码中使用xml注释。由于解释的数量,他们的混乱风格(我的意见)和当年,我将解释我的方法。它与其他解决方案相同,可能更容易理解,完全基于Tassos Bassoukos的公认解决方案:
- Find your needed source file in your JDK. There is a source.zip folder in your installation folder.
- Create a package in your project based on the Overriding one package implementation with another. This new package path corresponds to the path of your desired Java files. Add the
<super-source path="jre" />
annotation in your gwt.xml ! - Copy the files from (1.) in the new package and change their import declaration (All classes referencing the desired classes import the real java package path, not your custom one).
在JDK中找到所需的源文件。安装文件夹中有一个source.zip文件夹。
基于覆盖一个包实现与另一个包实现在项目中创建包。此新包路径对应于所需Java文件的路径。在gwt.xml中添加
从新包中复制(1.)中的文件并更改其导入声明(引用所需类的所有类导入真正的java包路径,而不是自定义路径)。
1 个解决方案
#1
1
You must keep the XML code out of the client or shared folder. You can use all classes and technologies on the server.
您必须将XML代码保留在客户端或共享文件夹之外。您可以使用服务器上的所有类和技术。
If you need to add annotations to shared classes, you need to add the xml annotations in a supersource path.
如果需要向共享类添加注释,则需要在超源路径中添加xml注释。
This is explained already here How to use JAXB annotations in the client side for GWT?
这里已经解释了如何在客户端使用JAXB注释进行GWT?
If this is not your issue, you may want to show some code you have tried that fails.
如果这不是您的问题,您可能希望显示您尝试过的失败代码。
#1
1
You must keep the XML code out of the client or shared folder. You can use all classes and technologies on the server.
您必须将XML代码保留在客户端或共享文件夹之外。您可以使用服务器上的所有类和技术。
If you need to add annotations to shared classes, you need to add the xml annotations in a supersource path.
如果需要向共享类添加注释,则需要在超源路径中添加xml注释。
This is explained already here How to use JAXB annotations in the client side for GWT?
这里已经解释了如何在客户端使用JAXB注释进行GWT?
If this is not your issue, you may want to show some code you have tried that fails.
如果这不是您的问题,您可能希望显示您尝试过的失败代码。