魔力宝贝炎洞多少层:一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码的例子
来源:百度文库 编辑:中财网 时间:2024/06/30 21:12:51
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码的例子 一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc
通过xml数据绑定可以省下很多写Javabean代码的时间。
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。 关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc xsd文件:
Comment describing your root element
登陆信息
用户名
密码
邮件地址
Email Address
收件人名字
xml文件:
lizongbo
lizongbopass
lizongbo @ gamil.com
lzb
java文件Userinfo.java:(Loginifo.java略去)/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Comment describing your root element
*
* @version $Revision$ $Date$
*/
public class Userinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 登陆信息
*/
private com.lizongbo..Loginifo _loginifo; /**
* Field _mailinfo
*/
private com.lizongbo..Mailinfo _mailinfo;
//----------------/
//- Constructors -/
//----------------/ public Userinfo() {
super();
} //-- com.lizongbo..Userinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘loginifo‘. The field ‘loginifo‘
* has the following description: 登陆信息
*
* @return the value of field ‘loginifo‘.
*/
public com.lizongbo..Loginifo getLoginifo()
{
return this._loginifo;
} //-- com.lizongbo..Loginifo getLoginifo() /**
* Returns the value of field ‘mailinfo‘.
*
* @return the value of field ‘mailinfo‘.
*/
public com.lizongbo..Mailinfo getMailinfo()
{
return this._mailinfo;
} //-- com.lizongbo..Mailinfo getMailinfo() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘loginifo‘. The field ‘loginifo‘ has
* the following description: 登陆信息
*
* @param loginifo the value of field ‘loginifo‘.
*/
public void setLoginifo(com.lizongbo..Loginifo loginifo)
{
this._loginifo = loginifo;
} //-- void setLoginifo(com.lizongbo..Loginifo) /**
* Sets the value of field ‘mailinfo‘.
*
* @param mailinfo the value of field ‘mailinfo‘.
*/
public void setMailinfo(com.lizongbo..Mailinfo mailinfo)
{
this._mailinfo = mailinfo;
} //-- void setMailinfo(com.lizongbo..Mailinfo) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Userinfo) Unmarshaller.unmarshal(com.lizongbo..Userinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
--------------------------------------------------/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Class Mailinfo.
*
* @version $Revision$ $Date$
*/
public class Mailinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 邮件地址
*/
private java.lang.String _addr = "lizongbo @ gamil.com"; /**
* 收件人名字
*/
private java.lang.String _person = "lzb";
//----------------/
//- Constructors -/
//----------------/ public Mailinfo() {
super();
setAddr("lizongbo @ gamil.com");
setPerson("lzb");
} //-- com.lizongbo..Mailinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @return the value of field ‘addr‘.
*/
public java.lang.String getAddr()
{
return this._addr;
} //-- java.lang.String getAddr() /**
* Returns the value of field ‘person‘. The field ‘person‘ has
* the following description: 收件人名字
*
* @return the value of field ‘person‘.
*/
public java.lang.String getPerson()
{
return this._person;
} //-- java.lang.String getPerson() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @param addr the value of field ‘addr‘.
*/
public void setAddr(java.lang.String addr)
{
this._addr = addr;
} //-- void setAddr(java.lang.String) /**
* Sets the value of field ‘person‘. The field ‘person‘ has the
* following description: 收件人名字
*
* @param person the value of field ‘person‘.
*/
public void setPerson(java.lang.String person)
{
this._person = person;
} //-- void setPerson(java.lang.String) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Mailinfo) Unmarshaller.unmarshal(com.lizongbo..Mailinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
通过xml数据绑定可以省下很多写Javabean代码的时间。
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。 关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc xsd文件:
xml文件:
java文件Userinfo.java:(Loginifo.java略去)/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Comment describing your root element
*
* @version $Revision$ $Date$
*/
public class Userinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 登陆信息
*/
private com.lizongbo..Loginifo _loginifo; /**
* Field _mailinfo
*/
private com.lizongbo..Mailinfo _mailinfo;
//----------------/
//- Constructors -/
//----------------/ public Userinfo() {
super();
} //-- com.lizongbo..Userinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘loginifo‘. The field ‘loginifo‘
* has the following description: 登陆信息
*
* @return the value of field ‘loginifo‘.
*/
public com.lizongbo..Loginifo getLoginifo()
{
return this._loginifo;
} //-- com.lizongbo..Loginifo getLoginifo() /**
* Returns the value of field ‘mailinfo‘.
*
* @return the value of field ‘mailinfo‘.
*/
public com.lizongbo..Mailinfo getMailinfo()
{
return this._mailinfo;
} //-- com.lizongbo..Mailinfo getMailinfo() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘loginifo‘. The field ‘loginifo‘ has
* the following description: 登陆信息
*
* @param loginifo the value of field ‘loginifo‘.
*/
public void setLoginifo(com.lizongbo..Loginifo loginifo)
{
this._loginifo = loginifo;
} //-- void setLoginifo(com.lizongbo..Loginifo) /**
* Sets the value of field ‘mailinfo‘.
*
* @param mailinfo the value of field ‘mailinfo‘.
*/
public void setMailinfo(com.lizongbo..Mailinfo mailinfo)
{
this._mailinfo = mailinfo;
} //-- void setMailinfo(com.lizongbo..Mailinfo) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Userinfo) Unmarshaller.unmarshal(com.lizongbo..Userinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
--------------------------------------------------/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Class Mailinfo.
*
* @version $Revision$ $Date$
*/
public class Mailinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 邮件地址
*/
private java.lang.String _addr = "lizongbo @ gamil.com"; /**
* 收件人名字
*/
private java.lang.String _person = "lzb";
//----------------/
//- Constructors -/
//----------------/ public Mailinfo() {
super();
setAddr("lizongbo @ gamil.com");
setPerson("lzb");
} //-- com.lizongbo..Mailinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @return the value of field ‘addr‘.
*/
public java.lang.String getAddr()
{
return this._addr;
} //-- java.lang.String getAddr() /**
* Returns the value of field ‘person‘. The field ‘person‘ has
* the following description: 收件人名字
*
* @return the value of field ‘person‘.
*/
public java.lang.String getPerson()
{
return this._person;
} //-- java.lang.String getPerson() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @param addr the value of field ‘addr‘.
*/
public void setAddr(java.lang.String addr)
{
this._addr = addr;
} //-- void setAddr(java.lang.String) /**
* Sets the value of field ‘person‘. The field ‘person‘ has the
* following description: 收件人名字
*
* @param person the value of field ‘person‘.
*/
public void setPerson(java.lang.String person)
{
this._person = person;
} //-- void setPerson(java.lang.String) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Mailinfo) Unmarshaller.unmarshal(com.lizongbo..Mailinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
在C#项目中怎么样使用自定义的命名空间啊?
一般网页文件的命名不`使用()进行命名
一般网页文件的命名不`使用()进行命名
.net中,怎样使用一个Xml Schema或者DTD去校验一个xml的格式是否正确?
如何使用QQ空间的自定义代码?
谁会使用百度空间的自定义设置
根据news.xsd写一个news.xml文档,元素内容要符合schema文件的定义,具体内容自己编辑。
这个格式的xml文件怎么用schema定义
文件禁止使用符号命名
C++中,头文件与命名空间的关系
QQ空间免费的自定义模版应该怎样使用?
关于XML schema的问题
求一个可以自定义模板的免费空间
Windows2000的文件命名规则
命名3721的是什么文件
关于一个空间的使用
如何使用CSocket类传输一个自定义的结构体
如何使用QQ空间自定义代码
如何使用QQ空间自定义代码
现在QQ空间可以使用自定义吗?
关于QQ空间JS文件的使用?
C#中如何创建一个有子项目的程序集,并且命名空间怎么解决
一个产品功能的命名?
我的QD存储卡里的sound文件夹里有一个ILLMAR~1文件,删不掉,造成铃声不能使用自定义的.