-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Make ToXmlGenerator
non-final
#262
Comments
It'd be possible to remove That said, there are no good extension points for variable interpolation either during parsing or generation. I have plans to support something for parsing (and there's an issue for The way I would probably try to tackle this, however, would not be at |
For what it's worth, here's a script that interpolates and transforms a YAML document into XML:
I'd like to eliminate the Ruby and Python dependencies:
That'd be the simplest solution.
It is not trivial to add interpolation during parsing. Consider:
Afterwards, though, interpolating the values is easy.
Where can I find an example of serialization that performs operations on values during write operations in a generic way (i.e., not coupled to any instance variables specific to a known YAML document structure)? Here's a
However, there's no instance variable that can have the |
Right, in streaming manner some interpolation is doable, others not. Hooks for allowing some level of modification are needed for other purposes as well (low-level coercion, f.ex, from loosely typed textual formats), so it's not just for this use case. As to serializer, I am not sure I understand your question. Context that can be used to pass configuration, settings, would be But I may be missing some aspects you are looking for... ? |
A bean implies a POJO; there can be no POJOs in a general purpose solution. There are no POJOs in my code to annotate. To be clear, here's an example file called
I'd like to transform the contents of
The input file
Transforming would produce:
The following class creates a serializer:
The serializer class is registered as follows:
The
Even if the
I also tried using an
Along with the following code:
The method Is there any other way to intercept the value immediately prior to being written? If I'm missing something in the implementation, please let me know. |
ToXmlGenerator
non-final
This might be too little, too late, but I figured there is no reason |
# Conflicts: # release-notes/CREDITS-2.x # release-notes/VERSION-2.x
Background
A YAML file contains definitions that reference each other using a simple syntax:
The goal is to read the YAML definitions, interpolate the values, then write them back out. The output formats include YAML and XML. YAML works fine. XML, however, does not.
For context, the YAML implementation intercepts the
writeString
method ofYAMLGenerator
. Note that theYAMLGenerator
class is not declaredfinal
. The following code works:The
ResolverYAMLGenerator
subclasses fromYAMLGenerator
and overrides thewriteString
method to perform variable interpolation via thesubstitute
method call.Problem
The equivalent XML generator class,
ToXmlGenerator
, is declared final. This precludes the possibility of overriding itswriteString
method to perform variable interpolation.Resolution Ideas
Can
ToXmlGenerator
have itsfinal
declaration removed?If not, what other mechanism exists to interpolate only element values immediately prior to writing them (that don't involve composition and delegation)?
The text was updated successfully, but these errors were encountered: