当前位置:网站首页>XMLBean的基础运用
XMLBean的基础运用
2022-07-30 05:44:00 【victorkevin】
- 根据xml schema生成xml
- Schema文件定义如下:
- xml version="1.0" encoding="UTF-8"?>
- <xs:schema xmlns="http://mydomain.com/myApp" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://mydomain.com/myApp" elementFormDefault="qualified" attributeFormDefault="unqualified">
- <xs:element name="e1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="e11" type="xs:int"/>
- <xs:element name="e12">
- <xs:complexType>
- <xs:attribute name="e121" type="xs:string" use="required"/>
- <xs:attribute name="e122" type="xs:long"/>
- xs:complexType>
- xs:element>
- xs:sequence>
- xs:complexType>
- xs:element>
- xs:schema>
- 请用xmlBean生成jar包,并编写一个程序生成一个xml文件,其中e11=11 e121=”e121”。
PS:输入如下命令之前,务必设置好环置变量
命令如下:
Scomp –src build\src –out build\myApp.jar myApp.xsd
如果成功运行,在当前目录下会生成一个myApp.jar文件,然后把它添加到classpath下
- 程序如下:
- 注— Version xmlbeans-2.3.0 程序经过测试成功
- import com.mydomain.myApp.*;
- import com.mydomain.myApp.impl.*;
- import org.apache.xmlbeans.XmlOptions;
- import java.io.*;
- public class MyAppDemo{
- public static void main(String[] args)throws Exception{
- .E1Document e1Doc=E1Document.Factory.newInstance();
- E1Document.E1 e1=e1Doc.addNewE1();
- e1.setE11(11);
- E1Document.E1.E12 e12=e1.addNewE12();
- e12.setE121("e121");
- File file=new File("myApp.xml");
- e1Doc.save(file);
- }
- }
边栏推荐
- TDengine cluster construction
- Xcode 绑定按钮点击事件
- 工厂模式(Swift 实现)
- 【MySQL功法】第5话 · SQL单表查询
- C语言学习经验
- Use kotlin to extend plugins/dependencies to simplify code (after the latest version 4.0, this plugin has been deprecated, so please choose to learn, mainly to understand.)
- MySQL 数据类型及占用空间
- Mysql client common exception analysis
- Using custom annotations, statistical method execution time
- TDengineGUI cannot connect to TDengine
猜你喜欢
随机推荐
二十二、Kotlin进阶学习:简单学习RecyclerView实现列表展示;
GraphQL (1) Basic introduction and application examples
Student achievement management system (C language version)
史上超强最常用SQL语句大全
根据ip地址获取地理位置及坐标(离线方式)
Using PyQt5 to add an interface to YoloV5 (1)
MySQL special statement and optimizer
TDengine cluster construction
Mysql 客户端常见异常分析
Bubble sort, selection sort, insertion sort, quick sort
SQL Server 数据库之生成与执行 SQL 脚本
The first WebAssembly program
十四、Kotlin进阶学习:一、内联函数 inline;二、泛型;三、泛型约束;四、子类与子类型;
【调优】一个 Spark 任务某天突然变慢怎么解决
【数仓】数据质量
常用损失函数(二):Dice Loss
学生成绩管理系统(C语言版)
MySQL data types and footprint
Redis publish/subscribe
"MySQL Advanced Chapter" four, the storage structure of the index







