当前位置:网站首页>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);
- }
- }
边栏推荐
- [MATLAB]图像处理——交通标志的识别
- 【OS】操作系统高频面试题英文版(1)
- Using custom annotations, statistical method execution time
- 原型模式(Prototype):Swift 实现
- [Getting C language from zero basis - navigation summary]
- Mysql client common exception analysis
- Redis 发布/订阅
- Servlet基本原理与常见API方法的应用
- MySQL data types and footprint
- MySQL - Function and Constraint Commands
猜你喜欢

Online sql editing query tool sql-editor

Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型

Flink CDC 实现Postgres到MySQL流式加工传输案例

十六、Kotlin进阶学习:协程详细学习。

SQL Server安装教程

sql中 exists的用法

SQL Server 数据库之生成与执行 SQL 脚本

FastAPI 快速入门

Jackson serialization failure problem - oracle data return type can't find the corresponding Serializer

工厂模式(Swift 实现)
随机推荐
MySQL 索引的数据结构及类型
学生管理系统
FastAPI 快速入门
Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型
AAcell五号文档室——跨平台文件传输的小室一间一间的
史上超强最常用SQL语句大全
MySQL - 函数及约束命令
Xcode 绑定按钮点击事件
使用PyQt5为YoloV5添加界面(一)
C语言学习经验
MySQL achievement method 】 【 5 words, single table SQL queries
C语言实战小项目(传统卡牌游戏)
十七、Kotlin进阶学习:1、守护线程;2、线程和协程之间的效率对比;3、取消协程;
TDengine cluster construction
Trust anchor for certification path not found. Exception solution.
Go简单实现协程池
SQL Server Installation Tutorial
Mysql client common exception analysis
Student achievement management system (C language version)
Detailed explanation of ClickHouse query statement