-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add save extra namespaces #18
base: trunk
Are you sure you want to change the base?
Conversation
Added the saveExtraNamespaces input parameter and modified the top-level element to write to disk to ensure that the top-level element can write extraNamespaces
Could you add a unit test? |
OK,I will do this |
@whatever098 could you give some background on why adding the unused extra namespaces is useful? I'm struggling to see how this is useful. |
@pjfanning When we save the java code generated by xsd as xml, we need this method to set the namespace |
XMLBeans adds the namespace declarations that it needs. I'm against merging this. What if someone adds an 'extra namespace' with the same prefix as one that XMLBeans generates for its own needs? We've gone 20 years without needing this support. Provide a very detailed example of why you need this - something that fails without this support - or I will remain against adding this. You are free to fork XMLBeans and add whatever you like to your fork. |
assertEquals("http://www.nits.org.cn/uof3/zh-cn/2021/graph", root.getAttribute("xmlns:图")); | ||
assertEquals("http://www.nits.org.cn/uof3/zh-cn/2021/wordproc", root.getAttribute("xmlns:字")); | ||
assertEquals("http://www.nits.org.cn/uof3/zh-cn/2021/spreadsheet", root.getAttribute("xmlns:表")); | ||
assertEquals("http://www.nits.org.cn/uof3/zh-cn/2021/presentation", root.getAttribute("xmlns:演")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a single one of these namespaces is used in the XML. I am -1 to merging this. I see no point in supporting adding unused namespace declarations.
@pjfanning Let me explain the reason in detail. When I generate a jar with an xsd containing some namespace(such as |
55b6a1d
to
16af8f6
Compare
I will not merge this unless there are checks so that the extra namespaces do not clash with the namespaces that XMLBeans generates for itself. |
Actually, I think we should abandon this and work out why XMLBeans does not generate the correct namespaces in the 1st place. |
You are right,I will try |
@pjfanning I review my modified and found using setSaveImplicitNamespaces can achieve my appeal, but using this method will traverse the XML files twice, this could lead to problems in the performance of some of the scenes, so now I will use setSaveImplicitNamespaces moment, There may be time later to commit changes to the PR to add some checks during my free time.By the way, can you deal with the pr #19 as soon as possible, this matters to me. |
Added the saveExtraNamespaces input parameter and modified the top-level element to write to disk to ensure that the top-level element can write extraNamespaces