当前位置:网站首页>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);
- }
- }
边栏推荐
- 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.)
- Request请求体重新封装,解决请求体只能获取一次的问题
- Trust anchor for certification path not found. Exception solution.
- Nacos配置中心用法详细介绍
- The types of data structures and MySQL index
- sqli-labs shooting range SQL injection learning Less-1
- C语言实战小项目(传统卡牌游戏)
- GraphQL(一)基础介绍及应用示例
- oracle row to column, column to row summary
- TDengine集群搭建
猜你喜欢

Mycat2.0 build tutorial
![Monstache执行monstache -f config.toml出错No processor type exists with name [attachment] [type=parse_exc](/img/2d/50c9001125cd613087044d2b6c78b1.png)
Monstache执行monstache -f config.toml出错No processor type exists with name [attachment] [type=parse_exc

MySQL - Function and Constraint Commands

Pytorch(二):数据读取机制(DataLoader、DataSet)与图像预处理模块(transforms)

nodejs PM2监控及报警邮件发送(二)

【Spark】Spark 高频面试题英语版(1)

十一、Kotlin进阶学习:1、集合;2、List操作;3、可变集合——MutableList;4、Set;5、Map;6、MutableMap;
Go简单实现协程池

Xcode 绑定按钮点击事件

FastAPI Quick Start
随机推荐
A Spark task tuning 】 【 one day suddenly slow down how to solve
nodejs PM2监控及报警邮件发送(二)
Using custom annotations, statistical method execution time
【OS】操作系统高频面试题英文版(1)
MySQL 特殊语句及优化器
Reasons and solutions for Invalid bound statement (not found)
Obtain geographic location and coordinates according to ip address (offline method)
oracle row to column, column to row summary
Arthas 命令解析(watch/tt/sc)
Flink PostgreSQL CDC配置和常见问题
MySQL - Function and Constraint Commands
C语言实战小项目(传统卡牌游戏)
awd --waf deployment
Xcode 绑定按钮点击事件
Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型
史上超强最常用SQL语句大全
The Request request body is repackaged to solve the problem that the request body can only be obtained once
Mysql client common exception analysis
GraphQL (1) Basic introduction and application examples
十二、Kotlin进阶学习:一、Lambda 表达式;二、高阶函数;