-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow rewriting system ids for local files #19
Comments
I have following situation: |
Hi Julien, I think I've created an issue because of your (or someone else's) question Best wishes, On Thu, Nov 27, 2014 at 9:38 AM, JulienCharon notifications@github.com
|
@JulienCharon Could you please provide a test case (sample project)? |
@JulienCharon FYI thank you for the test case. Reproduced and working on it. |
Ok, this is indeed an issue. The problem is that relative URIs like
But this does:
Since entity resolver does not get the base URI, "relativize" the absolute URI back, so it actually can't guess that I think the solution should be some kind of expression like
When the catalog is parsed, |
Hi, |
This should be fixed in XJC. The workaround for the |
Unfortunatelly we can not use proposed workaround for plugin as XSDs are provided by 3rd party with schemaLocation given as relative local file URI. Changing schemaLocation to arbitrary absolute URI every time we receive XSD update is not desirable. Is this plugin issue planned to be fixed in the future? |
You can still use this workaround. You just have to compile an URI instead of files. This is not a bug in the plugin, this is a problem in XJC. This XJC problem can be compensated for in the plugin, but since there's a workaround, this is not a high priority. We'd accept a Pull Request though. |
I have a different workaround that combines the build-helper-maven-plugin with the filter capabilities of the maven-resources-plugin. In the src/main/resources/catalog.cat file I have:
and in the pom.xml I have the following:
Note how the maven-jaxb2-plugin is configured to use the catalog.cat file that was output/filtered to target/classes/catalog.cat as opposed to the usual src/main/resources/catalog.cat The content of target/classes/catalog.cat is output as:
|
In case someone stumbles over the same problem (resolving local xsd files to xsds provided in jars) The above solution from @heatzync , as nice as it is, did not work for me. The internaly used MavenCatalogResolver was unable to resolve the given file path, no matter what I tried. My workaround was to write a custom The plugin with custom resolver: package;
import java.io.IOException;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.sun.tools.xjc.BadCommandLineException;
import com.sun.tools.xjc.Options;
public class CustomResolverPlugin extends com.sun.tools.xjc.Plugin {
//
public String getOptionName() {
return "Xcustom-resolver-plugin";
}
public String getUsage() {
return "-Xcustom-resolver-plugin";
}
// --------------------------------------------------------------------------------------- //
// --------------------------------------------------------------------------------------- //
/**
* Notifies a plugin that it's activated.
*/
@Override public void onActivated( Options opts ) throws BadCommandLineException {
opts.entityResolver = new CustomResolver( opts.entityResolver );
super.onActivated( opts );
}
//
static class CustomResolver implements EntityResolver {
private final EntityResolver resolver;
public CustomResolver( EntityResolver resolver ) {
this.resolver = resolver;
}
//
@Override public InputSource resolveEntity( String publicId, String systemId ) throws SAXException, IOException {
if( systemId != null && systemId.endsWith( "the-local-schema-file.xsd" ) ) {
systemId = "http://some-url/the-local-schema-file.xsd";
}
return resolver.resolveEntity( publicId, systemId );
}
}
} The catalog.cat resolving fake
|
I tried the above solution from @heatzync. First with no success. After some debugging I recognize, that ${project.basedir} used in catalog.cat expands on windows with file.separator="\".
To fix this I convert the variable content with help from build-helper-maven-plugin and regular expression. <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>enforce-unix-fileseparator</id>
<phase>validate</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<value>${project.basedir}</value>
<regex>\\</regex>
<replacement>/</replacement>
<name>project.basedir.unixfmt</name>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin> and changed entries in catalog.cat to use the new variable: Now @heatzync's solution works without problems even under Windows |
…com.helger-ph-commons-parent-pom-9.5.5 Bump ph-commons-parent-pom from 9.5.4 to 9.5.5
@ScrambledRK / @rudolfa |
@ScrambledRK / @rudolfa / @JulienCharon / @Milbor-zz / @heatzync : provided a PR that fixes this with a simple new parameter |
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key - Maven plugin updates
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key - Maven plugin updates
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key - Maven plugin updates
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key - Maven plugin updates
- Disable gh-19 - Convert jaxb-annox to proper bundle (don't leave edited file on disk for release) - Disable gpg signing for CI testing - Add dummy gpg key - Maven plugin updates
Partial fix in 2.0.8 release for JDK11 / JDK17, but failed fix for JDK8 due to CatalogManager class collision between dependency and rt.jar |
No description provided.
The text was updated successfully, but these errors were encountered: