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

Java short name #19

Closed
wants to merge 2 commits into from
Closed

Java short name #19

wants to merge 2 commits into from

Conversation

pjfanning
Copy link
Contributor

@pjfanning pjfanning commented Jun 24, 2024

see #15

The source code encoding param was added separately using #16

fyi @whatever098 - would you be able to provide a detailed description of what problem you have (with examples) and how this code solves it?

@whatever098
Copy link

This modification is due to the issue that when the XSD file contains Chinese labels, the generated paths include Chinese characters, causing the JAR file to fail execution. Therefore, Java short names are used to avoid this problem.

@pjfanning
Copy link
Contributor Author

@whatever098 I took your uof.xsd from #18 (comment) and I was able to get scomp to build classes and a jar for the xsd.

Used this command:

bin/scomp -sourcecodeencoding utf-8 -src mysrc uof.xsd 

I built XMLBeans using the latest trunk code.

I don't see a need for this PR.

@whatever098
Copy link

@pjfanning More precisely, the reason is that we expect to generate the alias of the tag as the name of the xsbs in the jar, rather than the tag name. there is not any problem in the usage of you command, but the generated jar uses Chinese names as xsb's names. So this will cause the xsb to not be found at runtime.
Take uof.xsd as an example. When shortjavaname is not used, the generated jar will look like this:
屏幕截图 2024-07-08 154421

@pjfanning
Copy link
Contributor Author

I tested the jar I generated and was able to use it ok with no issues.

package org.example;

import cn.org.nits.uof3.zhCn.x2021.uof.用户类型;

public class Main {
    public static void main(String[] args) {
        用户类型 o1 = 用户类型.Factory.newInstance();
        用户类型.文档标识0004 o2 = o1.addNew文档标识0004();
        o2.set标识符B6EC("标识符B6EC");
        System.out.println(o1);
    }
}

@whatever098
Copy link

I tested the jar I generated and was able to use it ok with no issues.

package org.example;

import cn.org.nits.uof3.zhCn.x2021.uof.用户类型;

public class Main {
    public static void main(String[] args) {
        用户类型 o1 = 用户类型.Factory.newInstance();
        用户类型.文档标识0004 o2 = o1.addNew文档标识0004();
        o2.set标识符B6EC("标识符B6EC");
        System.out.println(o1);
    }
}

Are you running in Windows or Linux?

@pjfanning
Copy link
Contributor Author

I tested the jar I generated and was able to use it ok with no issues.

package org.example;

import cn.org.nits.uof3.zhCn.x2021.uof.用户类型;

public class Main {
    public static void main(String[] args) {
        用户类型 o1 = 用户类型.Factory.newInstance();
        用户类型.文档标识0004 o2 = o1.addNew文档标识0004();
        o2.set标识符B6EC("标识符B6EC");
        System.out.println(o1);
    }
}

Are you running in Windows or Linux?

Macbook.

@whatever098
Copy link

whatever098 commented Jul 8, 2024

@pjfanning I am now using the trunk branch to test some xsd on my computer. I did not find any problems, but the above problem existed when I used xmlbeans-5.1.1 before. It should be that there are some related fixes for this problem in the trunk. In this case, this PR is unnecessary and you can close it immediately. Thank you for your help.

@pjfanning pjfanning closed this Jul 8, 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