/* 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. */ XMLBeans Development Kit Version 5.0.0 Welcome to XMLBeans! Kit contents: (1) One copy of xmlbeans-5.0.0.jar, which contains XMLBeans. Should work on any JDK 1.8.x or newer. ./lib/xmlbeans-5.0.0.jar (2) License information for XML Beans and included libraries ./LICENSE.txt ./NOTICE.txt (3) One folder full of command-line scripts, pointing to the useful main() functions in the JAR. ./bin (4) A copy of the plain javadoc tree for org.apache.xmlbeans.* ./docs/javadocs (5) Samples that show the use of the XMLBeans API. (You'll also find more samples at the XMLBeans web site.) ./samples Where to start? (1) Setup. 1. Make sure you have a JDK 1.8.x or later installed; that java[.exe] is on your path and that JAVA_HOME/bin contains java[.exe], javac[.exe], and jar[.exe]. 2. Set your XMLBEANS_HOME env variable to point to the directory in which you installed XmlBeans (i.e., /home/user/xmlbeans). 3. Put the scripts in ./bin on your path. 4. To test your setup, run "scomp" with no arguments. You should get a "usage" message. (2) Get to know XMLBeans basics. 1. Use the tutorial located at the XMLBeans web site: http://xmlbeans.apache.org/documentation/tutorial_getstarted.html. This provides a hands-on introduction to the most commonly used technologies in XMLBeans. 2. For an even shorter introduction, see the Getting Started topic included with the release (./docs/guide/conGettingStartedwithXMLBeans.html) or at the web site (http://xmlbeans.apache.org/docs/2.2.0/guide/conGettingStartedwithXMLBeans.html). 3. Explore the samples provided with the release (./samples) or at the XMLBeans web site (http://xmlbeans.apache.org/samples/index.html). (3) Get more XMLBeans depth by compiling other schemas to understand and use generate Java types. * In the ./schemas directory you'll find some collections of schemas you can try out. - easypo: a contrived simple starter "purchase order" - nameworld: another simple schema - numerals: schema illustrating the use of various flavors of XmlSchema simple types - s4s: the Schema for Schema and Schema for XML To compile them, you can just send the whole directory to scomp, "scomp samples", or compile each file individually, "cd samples"; then "scomp easypo.xsd". You will get an "xmltypes.jar" out that contains all the compiled XMLBeans. To pick your own JAR filename just say scomp -out myeasypo.jar easypo.xsd * Especially as you get started, you will want to see the .java source code for the generated code. To get that, use a command-line like scomp -src mysrcdir -out myeasypo.jar easypo.xsd The "mysrcdir" will contain all the .java source code for the generated XMLBeans. * You can also use the XMLBean Ant task to compile your schemas during your build process: For more information, see docs/guide/antXmlbean.html. (4) Learn more about code generated from your schema and about the XMLBeans API. Armed with the XMLBeans source code and the basic docs, you're ready to program. Things you need to know: * The org.apache.xmlbeans package has all the public classes for XMLBeans. Programs should not need to call anything else in xbean.jar directly. * XmlObject is the base class for all XMLBeans. It corresponds to xs:anyType. * Every schema type corresponds to an XMLBean interface, e.g., XmlAnySimpleType corresponds to xs:anySimpleType, and XmlInt corresponds to xs:int, etc.. And of course this extends to the XMLBean classes compiled from user-defined schemas. * Every XMLBean interface has an inner Factory class for creating or parsing instances, e.g., to load a file of generic type, use XmlObject.Factory.parse(myfile); to parse a string you expect to be a purchase-order, use PurchaseOrderDocument.Factory.parse("