Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Java short name#19

Closed
pjfanning wants to merge 2 commits intoapache:trunk from
pjfanning:java-short-name
Closed

Java short name #19
pjfanning wants to merge 2 commits intoapache:trunk from
pjfanning:java-short-name

Conversation

@pjfanning
Copy link
Member

@pjfanning pjfanning commented Jun 24, 2024
edited
Loading

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?

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.

Copy link
Member 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.

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

Copy link
Member 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);
 }
}

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?

Copy link
Member 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.

Copy link

whatever098 commented Jul 8, 2024
edited
Loading

@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 reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /