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

xmlbeans supports Chinese tags to generate java source code and build JAR package #15

Open
wants to merge 6 commits into
base: REL_5_1_1
Choose a base branch
from

Conversation

whatever098
Copy link

[Reason: xmlbeans-REL_5_1_1 does not support Chinese paths (essentially, javac on the win platform does not support Chinese source code paths)]

1.Add two command line parameters to control whether to use the new encoding method to generate Java source code and build the JAR package.
2.Add properties in the options to support the above changes.
3.During compilation, select different generation logic by checking whether the "usecustom" and "useshortname" parameters are present.
4.Add in-code unit tests for verification.

…ly, javac on the win platform does not support Chinese source code paths)]

1.Add two command line parameters to control whether to use the new encoding method to generate Java source code and build the JAR package.
2.Add properties in the options to support the above changes.
3.During compilation, select different generation logic by checking whether the "usecustom" and "useshortname" parameters are present.
4.Add in-code unit tests for verification.
@pjfanning
Copy link
Contributor

I'll have a fuller look another time - maybe next week.

I would prefer if the encoding param was the name of the encoding to use. I would suggest a name of sourceCodeEncoding because this param applies to the compilation of source code and not general runtime operations.
Maybe the other config should be called something like useJavaShortName.

@@ -107,6 +107,7 @@ public enum XmlOptionsKeys {
SAVE_CDATA_LENGTH_THRESHOLD,
SAVE_CDATA_ENTITY_COUNT_THRESHOLD,
SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES,
SAVE_EXTRENAMESPACES,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be SAVE_EXTRA_NAMESPACES?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right,I will fix it.

@whatever098
Copy link
Author

I'll have a fuller look another time - maybe next week.

I would prefer if the encoding param was the name of the encoding to use. I would suggest a name of sourceCodeEncoding because this param applies to the compilation of source code and not general runtime operations. Maybe the other config should be called something like useJavaShortName.

OK,Thank you, and I look forward to your prompt response.

return setCompileSourceCodeEncoding (true);
}

public XmlOptions setCompileSourceCodeEncoding (boolean b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestion was that the input should be a string - the name of an encoding, eg "utf-8"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll fix it tomorrow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #16 - this is just an initial change, needs more work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #16 - this is just an initial change, needs more work

Maybe you have the wrong branch? My changes are based on branch REL_5_1_1 instead of trunk, but your PR#16 is based on trunk

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code using all your changes and added the ones I missed before, is there anything else I need to modify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing these changes is hard. XMLBeans does't have great support for testing the code generation support.
If you can build this yourself and see if it does the job for you then that's great.
I will try to get #16 merged at some stage - but only when I have time to build and test it.
I am omitting some of your changes (like extra namespaces) because I would prefer to do separate PRs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I will upload it to a separate PR soon,and for the version #16 I will test it tomorrow when I go to work👍

Copy link
Author

@whatever098 whatever098 Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pjfanning I just fixed a small problem and then used the jar with the command line parameters "-sourcecodeencoding UTF-8 -usejavashortname" to test my project. The build was successful and the unit tests passed completely. It will be fine after you apply my commit.(:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted that issue independently and already have a fix in #16

s_zhangziang added 4 commits June 19, 2024 14:27
2. Supplement changes missed in PR:
xmlbeans adds an interface for saving xmlobject objects to zip.
Add saveExtraNamespaces input parameter in xmlbeans, and modify the top-level element writing to disk to ensure that the top-level element can write extraNamespaces.
@pjfanning pjfanning mentioned this pull request Jun 24, 2024
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.

2 participants