当前位置:网站首页>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);
- }
- }
边栏推荐
- 【数仓】数据仓库高频面试题题英文版(1)
- 使用PyQt5为YoloV5添加界面(一)
- 在不同的服务器上基于docker部署redis主从同步
- Detailed introduction to the usage of Nacos configuration center
- 【零基础搞定C语言——导航汇总篇】
- MySQL 特殊语句及优化器
- sqli-labs shooting range SQL injection learning Less-1
- oracle行转列、列转行总结
- 十五、Kotlin进阶学习:一、子类与子类型;二、协变;三、逆变;
- Bubble sort, selection sort, insertion sort, quick sort
猜你喜欢

oracle行转列、列转行总结

八、Kotlin基础学习:1、数据类;2、单例;3、伴生对象;4、密封类;

Online sql editing query tool sql-editor

Flink CDC implements Postgres to MySQL streaming processing transmission case

在不同的服务器上基于docker部署redis主从同步
phpok website vulnerability exploitation analysis

Xcode 建立 UIKit 项目(Hello World)

《MySQL高级篇》四、索引的存储结构
awd --waf deployment

建造者模式(Swift 实现)
随机推荐
shardingsphere 分库分表及配置示例
Arthas command parsing (watch/tt/sc)
十五、Kotlin进阶学习:一、子类与子类型;二、协变;三、逆变;
Competition WP in May
Redis 客户端常见异常分析
建造者模式(Swift 实现)
【SQL】SQL 高频面试题英语版(1)
MySQL special statement and optimizer
[MATLAB] Image Processing - Recognition of Traffic Signs
sql concat() function
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.)
JVM Learning (2) Garbage Collector
Nodejs PM2 monitoring and alarm email (2)
在不同的服务器上基于docker部署redis主从同步
MySQL index optimization and failure scenarios
Volatility memory forensics - command shows
十六、Kotlin进阶学习:协程详细学习。
Xcode 绑定按钮点击事件
Request请求体重新封装,解决请求体只能获取一次的问题
The number of warehouse 】 data quality