1, Introduction to Xmlbeans
XMLBeans is a tool that allows you to access the full power of XML in a Java friendly way. It is an XML-Java binding tool. The idea is that you can take advantage the richness and features of XML and XML Schema and have these features mapped as naturally as possible to the equivalent Java language and typing constructs. XMLBeans uses XML Schema to compile Java interfaces and classes that you can then use to access and modify XML instance data. Using XMLBeans is similar to using any other Java interface / class, you will see things like getFoo or setFoo just as you would expect when working with Java. While a major use of XMLBeans is to access your XML instance data with strongly typed Java classes there are also API's that allow you access to the full XML infoset ( Xmlbeans Keeps Full XML Infoset Fidelity) AS Well As To Allow You to Reflect Into The XML Schema Itself THROUGH AN XML Schema Object Model.
Translation: XMLBeans is a tool that can access the powerful features of XML in Java. It is a tool that binds XML and Java. This means that you can enjoy the super feature of XML and XML Schema, and you can convert it well to Java code. Xmlbeans use XML Schema to compile into Java interfaces and classes so that you can use to access and modify instantiated XML data. Using XMLBeans, like the Java interface / class, you will see methods such as SET and GET, which are often used in Java. The main use of XMLBeans is to access instantiated XML data by a powerful Java class. Using the API in the Java class to access all elements in XML (XMLBeans is well saved, "also allows you to show through the XML Schema object model XML Schema itself.
2. Write XML Schema
For example: [Template.xsd]
XML Version = "1.0" encoding = "GB2312"?>
xsd: sequence>
xsd: complexType>
xsd: schema>
3, compile SCHEMA
Note: It was originally required to be compiled by the environment, but Apache offers a window directly compiled. The next time you write how the XMLbeans environment is built!
(1) Enter: http://xmlbeans.webappshosting.com/schematoolsv2/compile.do (Note: Xmlbeans version is 2.0)
(2) Select Multi-Box: Keep Xmlbeans Java Source (You can view the source code) and Enable Downloads (you can download the JAR package), enter the name of the JAR package (such as: schemaoftemplate.jar)
(3) Download the JAR package (note: Can not be used directly, to re-play, because there is no meta-inflicity in the package)
(4) Creator.cms.template.data.templatedocument and creatist.cms.template.data.template two primary classs and some attachment classes 4, download XMLBeans-2.0.zip (http://xmlbeans.apache.org ), Use xbean.jar and jsr173_api.jar package
5, this can be used, as if you operate like the Template data structure, such as the SET and GET methods, great!
Import Creator.cms.Template.Data. *;
Import creator.cms.template.data.templatedocument. *;
Templatedocument Templatedocument = Templatedocument.Factory.newInstance ();
Template Template = Templatedocument.addnewtemplate ();
Template.setID (ID);
Template.setChinaname (China_name);
Template.setMainFileName (main_file_name);
Template.setrootpath (root_path);
Template.setMemo (MEMO);
Template.setCreateTime (create_time);
Template.SetcreateAuthor (Create_Author);
Template.setisopen (is_open);
Template.SetParentId (PARENT_ID);
Template.setisDirectory (is_directory);
Templatedocument.toString ()
template>
template>