Using JIBx to generate XSD from binding.xml - xsd

Is there a way to generate an XSD document automatically from the binding.xml used by JIBx? This is mainly to allow offline validation of the XML documents will be unmarshalled eventually.
I checked the JIBx homepage, it mentioned a tool called Schema Generator:
http://jibx.sourceforge.net/jibxtools/schema-example.html
but looks like the jibx-genschema.jar file is no longer part of the package anymore, as such I was wondering if there is any alternative
Thanks!

Here is the link to the original package.
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/xfire/jibx/genschema/jibx-genschema.jar

Schema generator main class is org.jibx.binding.Compile. It is available in jibx-bind.jar.
This jar can be added to your project with maven dependency org.jibx:jibx-bind:1.2.3 (for example).

The SchemaGen tool has been included in the jibx-tools.jar file for some time. See the JiBX Binding Generator page for instructions on running tools in the jar, just substitute the target class org.jibx.schema.generator.SchemaGen to run the schema generator.

Related

Are there any XSD files to validate XML for the https://www.w3.org/TR/widgets/ namespace?

In the intelliJ suite, xsd validation is performed automatically and you get an error if a given schema is not found. I tried to find an xsd file for the w3c widgets namespace but i couldn't.
If there is no such thing, what is the best practice here? Just add a rule to each file to ignore the error? (that is not a good one imo)
Generate a schema automatically from the file? (but if i add something i need to regenerate it?)

DiscussionComment entity has Oracle reserved word as a column causing database generation error

When I try to use the stereotype DISCUSSION with Oracle I get an error because of the entity DiscussionComment column named "comment". Although I'm using the correct dialect for my Oracle version, Hibernate is not quoting DDL as needed. This is a very common problem with simple solution. I just want to apply the solution to OpenXava.
I tried to change the DiscussionComment source in OpenXava project (the one that comes with the OpenXava IDE). I changed the column name but it had no effect.
What and where should I change to alter the mapping of the entity?
The same problem applies to "YourFirstEntity", the demo entity of every project because of the "date" column.
Add the property hibernate.globally_quoted_identifiers to true in your persistence unit in persistence.xml
To modify OpenXava Java code, XML or i18n files:
Modify the code on OpenXava/src, OpenXava/xava or OpenXava/i18n.
Execute the Ant target buildOpenXava from
OpenXava/build.xml. It compiles the OpenXava Java code and creates
openxava.jar.
Refresh OpenXava project in Eclipse (F5).
Execute the Ant target updateOX from the build.xml of your own project.
Refresh your own project in Eclipse (F5).
reference:
https://openxava.org/OpenXavaDoc/docs/modify-openxava-code_en.html
Credits to #javierpaniza

How to read XSD schema from different location(Jar) while validation

I want to marshall and unmarshall a xsd. I have a jar say A.jar which contains one xsd file say 1.xsd. I am trying to validate it by using JAXB but it fails. 1.xsd is importing 3 more schema that is present in different jar (B. jar). How can I validate such that while validating it the 1.xsd could read the imported files that belongs to different jar (B.jar).
Assuming both jars are available on the classpath, it doesn't really matter that much whether the schema files are spread over different jars or not. If one schema imports or includes another schema, what matters is that the path can be resolved.
Suppose you have a package my.project.schemas which exists in A.jar and B.jar. In A.jar that package contains 1.xsd, which imports 2.xsd in the same package in B.jar. If the import element in 1.xsd looks like this...
<xs:import namespace="https://www.example.com" schemaLocation="2.xsd" />
then it should work. A resolver takes care of locating the other schema, and since the given schemaLocation is relative, the resolver will find it because it considers the same package across different jar files as the same location.
Things can get more complicated if there's different packages. In that case you'd need to use a relative path which may need to go up or down the package hierarchy to refer to the correct file (example: additional/2.xsd if package additional is a member of package my.project.schemas). Another option is to use a custom resolver. This lets you intercept the calls for external resources and resolve them programmatically.
Finally, note that the SchemaFactory used for creating a Schema object has a method that accepts an array of sources. If you create a Source for each schema file and supply all of them to the factory for creating a Schema object, this can avoid trouble with locations. In fact, you can just omit the schemaLocation attribute because the necessary references can be found among all the provided schemas.
In the past I've used JAXB with validating marshallers/unmarshallers that had to use schemas across different packages importing each other, which could also be across different jars. The last solution, providing a Source per schema to the factory method, was my preferred approach.

Generate XSD from Java WITH documentation

I created an XSD schema and have put in some documentation via the tag.
from the XSD i generated Java classes using Jaxb (from within eclipse - jdk1.6)
i now plan to use my java classes as "source" and modify them as per requirements that come up
I will generate XSD back from modified Java classes to keep the XSD in-sync.
in this process any "documentation" on the XSD gets lost. (i.e. when i generate it from Java). Is there some way to get around this? Thanks.

Does anyone know where to get the XSD file describing the junitReport.xml file format expected by Hudson?

I need the XSD of junitReport.xml recognized by Hudson.
Does anyone know where can it be found?
Thanks.
At this link, someone has already tried to analyse the JUnit code to check for any references for it's XML schema. But an XSD is no requirement to create XML and apparently, it doesn't use one.
I've create a junit.xsd for Ant's junit task. It was created by examining the relevant Java code in Ant 1.8.2

Resources