当前位置:网站首页>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);
- }
- }
边栏推荐
- MYSQL一站式学习,看完即学完
- Flink-流/批/OLAP一体得到Flink引擎
- 工厂模式(Swift 实现)
- Trust anchor for certification path not found. Exception solution.
- TDengineGUI cannot connect to TDengine
- Mysql client common exception analysis
- "MySQL Advanced Chapter" four, the storage structure of the index
- MySQL data types and footprint
- Detailed introduction to the usage of Nacos configuration center
- 九、Kotlin基础学习:1、Companion的扩展方法和扩展属性;2、一般类的扩展方法和扩展属性;3、委托;
猜你喜欢
随机推荐
oracle行转列、列转行总结
Flink PostgreSQL CDC configuration and FAQ
【零基础搞定C语言——导航汇总篇】
Competition WP in May
protobuf编码及网络通信应用(一)
MySQL 数据类型及占用空间
mysql delete duplicate data in the table, (retain only one row)
CNN经典模型发展进程
TDengine集群搭建
MySQL 特殊语句及优化器
Student management system
SQL Server安装教程
Using PyQt5 to add an interface to YoloV5 (1)
在线sql编辑查询工具sql-editor
Detailed explanation of regular expression syntax and practical examples
[MATLAB]图像处理——交通标志的识别
sql concat() function
MYSQL一站式学习,看完即学完
Twenty-two, Kotlin advanced learning: simply learn RecyclerView to achieve list display;
The first WebAssembly program









