Skip to content
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

addressing #41 #55

Merged
merged 2 commits into from
Aug 29, 2015
Merged

addressing #41 #55

merged 2 commits into from
Aug 29, 2015

Conversation

andrealbinop
Copy link
Contributor

@highsource,

I've implemented @victornoel XSLT approach, configurable with allowUnusedSchemaBindingsInEpisodes property. This worked for me, hopefully will help you resolve #41.

@andrealbinop andrealbinop changed the title addressing highsource/maven-jaxb2-plugin#41 addressing #41 Aug 25, 2015
@highsource
Copy link
Owner

Impressive, thank you.

@andrealbinop
Copy link
Contributor Author

You're welcome.

@victornoel
Copy link

Hi, that's great!

Maybe we should name differently the option.
To me, allowUnusedSchemaBindingsInEpisodes would be to accept episode files from dependencies even if they contain unused schema bindings (i.e. the second part of the solution discussed in issue #41).

But the first part, which is generating episode files with the if-exists attributes, is not about allowing anything. I don't know how to name it…

@andrealbinop
Copy link
Contributor Author

Got it. How about allowImporWithUnusedSchemaBindingsInEpisode? Maybe it's a little too big...couldn't think of anything shorter.

@victornoel
Copy link

Or we name it after the hack and not the objective, something like: applyEpisodeHackForUnusedSchemaBindings.

Also, do you think it would be hard to implement the complementary solution as part of this pull request? The idea would be to have the xsl applied to episodes while they are read, I think @highsource said in #41 that there was a way to introduce a resource resolver to do so.
For these maybe the configuration should be per episode (when there is many) and the properties would then be allowUnusedSchemaBindingsInEpisodes.

@highsource
Copy link
Owner

I think we'll really have to rework this with resolvers.

@andrealbinop
Copy link
Contributor Author

@victornoel,

Renamed the property as you suggested. @highsource, when you mention "rework this with resolvers" you mean adding XSLT transformation somewhere in MavenCatalogResolver?

@highsource
Copy link
Owner

Yep. The proposed solution transforms the generated episode file. Which is OK and good but does not help with existing episodes.
I think there's an option to implement something like an entity resolver for episodes which would transform them on acces in the runtime.

As for the episode generation I'd really think about fixing the XJC's episode plugin.
I'll have to think about it.

@victornoel
Copy link

Ok, so maybe as a first step, it would be better to fix reading of episodes (instead of generation) by using an entity resolver. As for the generation, it is actually not so important if we have the reading that works.

@andrealbinop
Copy link
Contributor Author

About fix reading of episodes, I couldn't find anything about episode's entity resolvers, nor I could think of a way to apply the XSLT transformation right before the episode file is parsed. @highsource , If you have a clear idea of how that could be acchieved maybe I can help.

I agree about fixing XJC's episode plugin to properly resolve the episode generation, this would definitely work for me, since in my case I'm not worried about existing episodes. As for now, I'll be using the hacked version of XSLT approach on generation until we find a proper solution.

@highsource
Copy link
Owner

I've thought about it, here's what I think.

The correct place to apply this fix would be the episode plugin in XJC:

https://github.com/gf-metro/jaxb/blob/69471fb27af6a9e990ef2a7873aab64a18e87640/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/addon/episode/PluginImpl.java

I'd add a "-episode-bindings-if-exists" option and consider it during the generation. This is where this fix actually belongs. @andreptb could you please consider sending a fix to the JAXB people as PR?

The problem is, however, that JAXB people don't really seem to be active in applying PRs. So not sure if they'd really do this.

Therefore I think having this workaround in maven-jaxb2-plugin is actually OK. I'd name the config element addEpisodeBindingsIfExists, nothing with "hacks" etc.

The implementation is OK. My suggestions would be:

@andreptb Would this be something you could overtake?

Now, about applying XSLT on read. This is a nice option, but seems quite complicated to me at the moment. I think, we'll solve, like the 80% case with just generating if-exists, so I'd leave it there first. If there will be a need, we'll address this in a new issue.

Thank you guys for your contributions!

highsource added a commit that referenced this pull request Aug 29, 2015
@highsource highsource merged commit 0bbe5b2 into highsource:master Aug 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Taking care of the "SCD "x-schema::tns" didnt match any schema component" error
3 participants