﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-andyj2ee-文章分类-xml</title><link>http://www.blogjava.net/andyj2ee/category/7407.html</link><description>java tec sky</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 12:58:43 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 12:58:43 GMT</pubDate><ttl>60</ttl><item><title>使用XMLBeans 进行java 数据梆定</title><link>http://www.blogjava.net/andyj2ee/articles/30628.html</link><dc:creator>java光环</dc:creator><author>java光环</author><pubDate>Tue, 14 Feb 2006 08:13:00 GMT</pubDate><guid>http://www.blogjava.net/andyj2ee/articles/30628.html</guid><wfw:comment>http://www.blogjava.net/andyj2ee/comments/30628.html</wfw:comment><comments>http://www.blogjava.net/andyj2ee/articles/30628.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/andyj2ee/comments/commentRss/30628.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/andyj2ee/services/trackbacks/30628.html</trackback:ping><description><![CDATA[<DIV>进入实践之前，最好找篇文章先了解一下 xmlbeans 是用来做什么的<BR>参考资料：<A href="http://xmlbeans.apache.org/">http://xmlbeans.apache.org/</A><BR>参考文章：<A href="http://www.onjava.com/pub/a/onjava/2004/07/28/XMLBeans.html">XML-Java Data Binding Using XMLBeans</A><BR><BR>xmlbeans bea 贡献的一个开源项目，目的是使xml 文件直接转化为java 对象，对java 对象的操作可直接存为xml 文件，省去了文档验证过程。<BR>实现原理：先定义 xml schema descripter ,编译定义的 *.xsd 文件，引入编译后生成的.jar 包。与 xmlbeans-Home\lib\xbean.jar&nbsp; 就可以在开发项目中使用了。<BR></DIV>
<DIV><BR>
<OL>
<LI><A href="http://xmlbeans.apache.org/documentation/conInstallGuide.html">Install XMLBeans.</A> 
<LI>Compile your schema. Use <A href="http://xmlbeans.apache.org/docs/2.0.0/guide/tools.html#scomp"><SPAN class=codefrag>scomp</SPAN></A> to compile the schema, generating and jarring Java types. For example, to create a employeeschema.jar from an employeesschema.xsd file: <PRE class=code>scomp -out employeeschema.jar employeeschema.xsd</PRE>
<LI>Write code. With the generated JAR on your classpath, write code to bind an XML instance to the Java types representing your schema. Here's an example that would use types generated from an employees schema: <PRE class=code>File xmlFile = new File("c:\employees.xml"); 

// Bind the instance to the generated XMLBeans types.
EmployeesDocument empDoc = 
	EmployeesDocument.Factory.parse(xmlFile); 

// Get and print pieces of the XML instance.
Employees emps = empDoc.getEmployees(); 
Employee[] empArray = emps.getEmployeeArray(); 
for (int i = 0; i &lt; empArray.length; i++) 
{ 
	System.out.println(empArray[i]); 
}</PRE></LI></OL></DIV><PRE class=code><FONT style="BACKGROUND-COLOR: #9acd32">实践中遇到的问题：<BR></FONT><STRONG><FONT style="BACKGROUND-COLOR: #9acd32">如何修改编译shema 产生的java 类的package 目录结构？</FONT></STRONG><BR><BR><BR>参考：<A href="http://wiki.apache.org/xmlbeans/XmlBeansFaq#configPackageName">http://wiki.apache.org/xmlbeans/XmlBeansFaq#configPackageName</A><BR><P><A id=configPackageName></A><STRONG>Can I change the default package names for the java classes generated from my schema?</STRONG> </P><P>You can create a file that ends in .xsdconfig to map targetnamespace to packagename. Put the .xsdconfig file in the same directory as the .xsd that you are compiling. Here is an example .xsdconfig: </P><PRE>&lt;!-- An xsdconfig file must begin with a "config" element in the 
        http://www.bea.com/2002/09/xbean/config namespace. Also, be sure
        to declare any namespaces used to qualify types in your schema (here,
        the namespace corresponding to the pol prefix. --&gt;
&lt;xb:config xmlns:pol="http://openuri.org/easypoLocal" 
    xmlns:xb="http://www.bea.com/2002/09/xbean/config"&gt;

    &lt;!-- Use the "namespace" element to map a namespace to the Java package
        name that should be generated. --&gt;
    &lt;xb:namespace uri="http://openuri.org/easypoLocal"&gt;
        &lt;xb:package&gt;org.openuri.easypo.xsdconfig&lt;/xb:package&gt;
    &lt;/xb:namespace&gt;

    &lt;!-- Use the "qname" element to map schema type names to generated
        Java type names. In these examples, the name attribute's value is the
        XML element name; the javaname attribute's value is the Java type 
        that should be generated. --&gt;
    &lt;xb:qname name="pol:CUST" javaname="Customer"/&gt;
    &lt;xb:qname name="pol:PURCH_ORDER" javaname="PurchaseOrder"/&gt;
&lt;/xb:config&gt;
</PRE><P>Notice that you can also map specific element/attribute names to java names. </P><P><IMG height=15 alt=/!\ src="http://wiki.apache.org/wiki/modern/img/alert.png" width=15> Note: If schema doesn't include targenamespace then use </P><PRE>&lt;xb:namespace uri="##any"&gt;
  &lt;xb:package&gt;org.openuri.easypo.xsdconfig&lt;/xb:package&gt;
&lt;/xb:namespace&gt;
</PRE><P>to specify package names </P><P><IMG height=15 alt=/!\ src="http://wiki.apache.org/wiki/modern/img/alert.png" width=15> Note: <A class=nonexistent href="http://wiki.apache.org/xmlbeans/XmlBeans">XmlBeans</A> doesn’t support using two or more sets of java classes (in different packages) mapped to schema types/elements that have the same names and target namespaces, using all in the same class loader. Depending on the direction you are using for the java classes to schema types mapping, some features might not work correctly. This is because even though the package names for the java classes are different, the schema location for the schema metadata (.xsb files) is the same and contains the corresponding implementing java class, so the JVM will always pick up the first on the classpath. This can be avoided if multiple class loaders are used. </P><BR>先看一下 scomp 命令: xmlbeans-home/bin 要加入到path 中，<BR><IMG alt="" hspace=0 src="C:\Documents and Settings\zhangjunqing\My Documents\My Pictures\xmlbeans-scomp.GIF" align=baseline border=0><BR>                             scomp 参数图<BR>编写自己的schema文件：weather_latlong.xsd<BR><DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:schema<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #ff0000">xmlns:xsd</SPAN><SPAN style="COLOR: #0000ff">="http://www.w3.org/2001/XMLSchema"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>xmlns:ct</SPAN><SPAN style="COLOR: #0000ff">="http://beans.jhalo.com"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>targetNamespace</SPAN><SPAN style="COLOR: #0000ff">="http://beans.jhalo.com"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>elementFormDefault</SPAN><SPAN style="COLOR: #0000ff">="qualified"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">&lt;!--</SPAN><SPAN style="COLOR: #008000">&nbsp;This&nbsp;XML&nbsp;Schema&nbsp;describes&nbsp;xml&nbsp;documents<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>containing&nbsp;either&nbsp;weather&nbsp;details&nbsp;or&nbsp;latlong<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>details&nbsp;of&nbsp;a&nbsp;location&nbsp;based&nbsp;on&nbsp;Zipcode&nbsp;Two&nbsp;Global<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>elements&nbsp;Weather&nbsp;and&nbsp;Latlong,&nbsp;and&nbsp;one&nbsp;Global<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Attribute&nbsp;Zipcode&nbsp;are&nbsp;declared.</SPAN><SPAN style="COLOR: #008000">--&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Weather"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:complexType</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:sequence</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Temperature"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:float"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Humidity"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:float"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Visibility"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:float"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Datetime"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:dateTime"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:sequence</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:attribute&nbsp;</SPAN><SPAN style="COLOR: #ff0000">ref</SPAN><SPAN style="COLOR: #0000ff">="ct:Zipcode"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:complexType</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:element</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Latlong"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:complexType</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:sequence</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Latitude"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:string"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:element&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Longitude"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:string"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:sequence</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:attribute&nbsp;</SPAN><SPAN style="COLOR: #ff0000">ref</SPAN><SPAN style="COLOR: #0000ff">="ct:Zipcode"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:complexType</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:element</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xsd:attribute&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Zipcode"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="xsd:string"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xsd:schema</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV><BR><BR>#<BR><BR><BR>2<BR>编写myconfig.xsdconfig 存放同一目录<BR><BR><BR>#<BR><DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:config&nbsp;</SPAN><SPAN style="COLOR: #ff0000">xmlns:xb</SPAN><SPAN style="COLOR: #0000ff">="http://xml.apache.org/xmlbeans/2004/02/xbean/config"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:ct</SPAN><SPAN style="COLOR: #0000ff">="http://beans.jhalo.com"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:namespace&nbsp;</SPAN><SPAN style="COLOR: #ff0000">uri</SPAN><SPAN style="COLOR: #0000ff">="http://beans.jhalo.com&nbsp;http://services.jhalo.com"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:package</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">org.jhalo</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:package</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:namespace</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:namespace&nbsp;</SPAN><SPAN style="COLOR: #ff0000">uri</SPAN><SPAN style="COLOR: #0000ff">="##any"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:prefix</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Xml</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:prefix</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:suffix</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Bean</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:suffix</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:namespace</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:qname&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="ct:Zipcode"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;javaname</SPAN><SPAN style="COLOR: #0000ff">="Zip"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">xb:qname&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="ct:Datetime"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;javaname</SPAN><SPAN style="COLOR: #0000ff">="Today"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">xb:config</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV><BR><BR>如果不使用myconfig.xsdconfig 进行编译 <BR>scomp -out weather.jar weather_latlong.xsd&nbsp; <BR>生成的 weather.jar 为：com/jhalo/beans/xxxx<BR><BR><BR>使用 .xsdconfig 编译<BR>scomp -out weather.jar weather_latlong.xsd&nbsp; myconfig.xsdconfig <BR>生成jar 结构为： org/jhalo/<BR><IMG alt="" hspace=0 src="C:\Documents and Settings\zhangjunqing\My Documents\My Pictures\xmlbeans-jar.GIF" align=baseline border=0><BR>在写测试程序发现, Datetime --&gt;Today 也改变了。<BR><DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;org.apache.xmlbeans.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;org.jhalo.XmlLatlongDocumentBean;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;org.jhalo.XmlWeatherDocumentBean;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>XmlWeatherDocumentBean&nbsp;wdoc;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>XmlWeatherDocumentBean.Weather&nbsp;w;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>wdoc&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;XmlWeatherDocumentBean.Factory.newInstance();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>w&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;wdoc.addNewWeather();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>w.setToday(Calendar.getInstance());</SPAN></DIV><BR>完毕.:)~</PRE><img src ="http://www.blogjava.net/andyj2ee/aggbug/30628.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/andyj2ee/" target="_blank">java光环</a> 2006-02-14 16:13 <a href="http://www.blogjava.net/andyj2ee/articles/30628.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>