xml生成xsd文件的方法

下载trang.jar  地址:http://download.csdn.net/detail/luoww1/8957991

将下载的包放在d:\xmlToxsd


第三步  生成XSD

假设在 d:\xmlToxsd 下有一个xml文件  person.xml

?
1
2
3
4
5
6
7
<? xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
< person NAME = "ZhangSan" >   
    < address country = "China" >       
       < state >beijing</ state >   
    </ address >   
    < Job >IT</ Job >
</ person >

打开windows命令行,将当前位置变更到 d:\xmlToxsd

输入

java -jar trang.jar  person.xml  person.xsd

 (  trang.jar 接受两个参数,第一个为源文件,第二个为目标文件)

ok!你可以看到在 d:\  下就生成了 person.xsd 文件

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<? xml version = "1.0" encoding = "UTF-8" ?>
< xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" elementFormDefault = "qualified"
    < xs:element name = "person" >   
       < xs:complexType >    
         < xs:sequence >       
           < xs:element ref = "address" />       
           < xs:element ref = "Job" />     
         </ xs:sequence >     
         < xs:attribute name = "NAME" use = "required" type = "xs:NCName" />   
       </ xs:complexType >
     </ xs:element
     < xs:element name = "address" >   
       < xs:complexType >    
         < xs:sequence >       
           < xs:element ref = "state" />      
         </ xs:sequence >     
         < xs:attribute name = "country" use = "required" type = "xs:NCName" />   
       </ xs:complexType
     </ xs:element
     < xs:element na<span style = "color:#000000;" >me="</ span >state" type="xs:NCName"/> 
     < xs:element name = "Job" type = "xs:NCName" />
</ xs:schema >
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值