xsd产生xml beans

Download castor1.3.1 example, and modify test.bat file as follow:

@echo off
REM Change the following line to set your JDK path
set JAVA_HOME=%JAVA_HOME%
set JAVA=%JAVA_HOME%\bin\java
set JAVAC=%JAVA_HOME%\bin\javac
set TPCL=C:\dev\castor\castor-1.3.1-examples-sources\lib\

@echo Create the classpath
echo %TPCL%
set CP=.;%TPCL%\castor-1.3.1-xml.jar;%TPCL%\castor-1.3.1-xml-schema.jar;%TPCL%\castor-1.3.1-codegen.jar;%TPCL%\castor-1.3.1-core.jar;%TPCL%\xercesImpl.jar;%TPCL%\commons-logging.jar;%JAVA_HOME%\lib\tools.jar;%TPCL%\lib\castor-1.3.1.jar


@echo.
@echo Using classpath: %CP%

@echo Castor Test Cases
@echo.
@echo Generating classes...

@rem Java 2 style collection types
@rem %JAVA% org.exolab.castor.builder.SourceGeneratorMain -i invoice.xsd -f -types j2 -binding-file bindingInvoice.xml
@rem Java 1.1 collection types
%JAVA% -cp %CP% org.exolab.castor.builder.SourceGeneratorMain -i test.xsd -f -package test.configuration.mapping.xmlimpl -dest .

@echo.
@echo Finish

%JAVAC% -classpath %CP% test\configuration\mapping\xmlimpl\descriptors\*.java

%JAVAC% -classpath %CP%;. *.java

@echo.
@echo Ready to run test case...
%JAVA% -cp %CP% TransactionTest


Test Code
import java.io.FileReader;

import test.configuration.mapping.xmlimpl.Begin;
import test.configuration.mapping.xmlimpl.Checkpoint;
import test.configuration.mapping.xmlimpl.End;
import test.configuration.mapping.xmlimpl.Transaction;

public class CastorTest {
public static void main(String[] args) {
try {
System.out.println("Unmarshalling Transaction");
Transaction transaction = Transaction.unmarshal(new FileReader("Test.xml"));
System.out.println();
System.out.println("unmarshalled...performing tests...");
System.out.println();
System.out.println("-------");
System.out.println();
System.out.println("test: " + transaction.getName()+"|"+transaction.getTimeout()+"|"+transaction.getSlatimeout());
} catch (Exception e) {
e.printStackTrace();
}
}
}


create a xml file for testing the generated code.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值