当前位置:网站首页>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);
- }
- }
边栏推荐
- Flink CDC 实现Postgres到MySQL流式加工传输案例
- Using custom annotations, statistical method execution time
- Redis 客户端常见异常分析
- Invalid bound statement (not found)出现的原因和解决方法
- [MATLAB]图像处理——交通标志的识别
- Arthas 命令解析(watch/tt/sc)
- 使用PyQt5为YoloV5添加界面(一)
- Mycat2.0搭建教程
- Pytorch(二):数据读取机制(DataLoader、DataSet)与图像预处理模块(transforms)
- Servlet基本原理与常见API方法的应用
猜你喜欢

SQL Server安装教程

21. Kotlin Advanced Learning: Implementing Simple Network Access Encapsulation
phpok website vulnerability exploitation analysis

Flink CDC implements Postgres to MySQL streaming processing transmission case

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.)

八、Kotlin基础学习:1、数据类;2、单例;3、伴生对象;4、密封类;
Go简单实现协程池

Xcode 建立 UIKit 项目(Hello World)

MySQL - 多表查询与案例详解

Xcode 绑定按钮点击事件
随机推荐
Servlet basic principles and application of common API methods
Function 函数式接口及应用
【SQL】first_value 应用场景 - 首单 or 复购
Redis 客户端常见异常分析
The Request request body is repackaged to solve the problem that the request body can only be obtained once
十四、Kotlin进阶学习:一、内联函数 inline;二、泛型;三、泛型约束;四、子类与子类型;
工厂模式(Swift 实现)
Request请求体重新封装,解决请求体只能获取一次的问题
MySQL data types and footprint
利用自定义注解,统计方法执行时间
十二、Kotlin进阶学习:一、Lambda 表达式;二、高阶函数;
正则表达式语法详解及实用实例
单例模式:Swift 实现
【数仓】数据仓库高频面试题题英文版(1)
Student achievement management system (C language version)
六、Kotlin基础学习:函数
Remember a traffic analysis practice - Anheng Technology (August ctf)
Volatility memory forensics - command shows
Flink-流/批/OLAP一体得到Flink引擎
Nacos配置中心用法详细介绍