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

Disable output escaping does not work using castor default configuration #63

Open
kovax opened this issue Oct 14, 2016 · 1 comment
Open

Comments

@kovax
Copy link

kovax commented Oct 14, 2016

I am trying to implement a CDATAFieldHandler, and it works fine except that the string value returned by the getValue() is escaped inthe final marshalled xml. Marshalling is done by this code segment:

    StringWriter sWriter = new StringWriter();
    Marshaller marshaller = mappingContext.createMarshaller();
    marshaller.setWriter(sWriter);
    marshaller.setMarshalAsDocument(false);

    if (obj instanceof Query) marshaller.addProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");

    marshaller.marshal(obj);
    return sWriter.toString();

mappingContext is an instance of XMLContext initalised at boot time by loading all of our mappings.

My test unmarshalls a hand-written xml and marshalls it back. Unmarshall works, the Object created correctly, but marshaller will convert the string escaped.

I use castor 1.4.1. and JavaSE 1.8

@jhaydtw
Copy link

jhaydtw commented Jul 19, 2017

I have a similar issue in 1.3.1 (on Java 7) where my code goes through the trouble to replace apostrophe (') with &apost; while creating a byte array stream, but when I unmarshall the stream into ojbects the encodings are changed back to apostrophes. This is causing the concatenation in the db code to fail.

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

No branches or pull requests

2 participants