使用Eclipse開發XMLBeans項目

來源:互聯網
上載者:User

介質準備

  Eclipse3.12下載地址:http://www.eclipse.org/downloads/

  XMLBean2.10下載地址:http://xmlbeans.apache.org/sourceAndBinaries/index.html

  JDK1.4+或JDK1.5+下載地址:http://java.sun.com/j2se/1.5.0/download.jsp
註:如果使用WebLogicServer,可以不用單獨安裝JDK,使用產品中內建的JDK即可 Eclipse配置   定義系統變數:   %XMLBEAN_HOME%:XMLBean的安裝目錄   %JAVA_HOME%:JDK安裝目錄   建立Java項目

  由於想使用JDK1.5,所以選擇5.0,為了專案管理方便,將原代碼與產生的二進位檔案分開存放

  一定要使用JDK而不是JRE,如果預設是JRE請重新定義

  定義自訂使用者類庫,並添加所有在%XMLBEAN_HOME%/lib下的Jar包


把xmlSchema檔案加入到工程中,例如加入hello.xsd.
<? xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  -->
< xs:schema  targetNamespace ="http://xmlbeans.apache.org/samples/template/sampletemplate"
    xmlns:xs ="http://www.w3.org/2001/XMLSchema"
    elementFormDefault ="qualified" >

     < xs:element  name ="hello" >
         < xs:complexType >
             < xs:sequence >
                 < xs:element  name ="name"  type ="xs:string"  maxOccurs ="unbounded" />
             </ xs:sequence >
         </ xs:complexType >
     </ xs:element >

</ xs:schema >
把ANT檔案加入到工程中,例如:
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  -->
< project  name ="SampleTemplate"  default ="build" >

     < property  environment ="env" />

     < path  id ="SampleTemplate.path" >
         < path  refid ="xmlbeans.path" />
         < fileset  dir ="build/lib"  includes ="*.jar" />
         < pathelement  path ="build/classes" />
     </ path >

     < target  name ="init"  depends  = "clean" >
         < property  name ="xmlbeans.home"  value ="${env.XMLBEANS_HOME}" />
         < echo  message ="xmlbeans.home: ${xmlbeans.home}" />

         <!--  check for xbean.jar from binary distribution  -->
         < available
             property ="xmlbeans.lib"
            value ="${xmlbeans.home}/lib"
            file ="${xmlbeans.home}/lib/xbean.jar"   />

         <!--  check for xbean.jar compiled from source  -->
         < available
             property ="xmlbeans.lib"
            value ="${xmlbeans.home}/build/lib"
            file ="${xmlbeans.home}/build/lib/xbean.jar"   />

         < fail  message ="Set XMLBEANS_HOME in your enviornment."
            unless ="xmlbeans.lib" />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.