xml to xsd ; xsd to xml
xml to xsd
工具网站
https://www.freeformatter.com/xsd-generator.html
http://xmlgrid.net/xml2xsd.html
示例xml
<?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
示例xsd结果
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="to"/> <xs:element type="xs:string" name="from"/> <xs:element type="xs:string" name="heading"/> <xs:element type="xs:string" name="body"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
xsd to xml
Spring Tool Suite 4 -> 右键 xsd 文件 -> Generate -> XML File... -> File Name -> Next -> Create optional attributes & create optional elements & Limit optional elment depth to: -> OK
如下示例:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration SYSTEM "mybatis-3-config.dtd" > <configuration> <properties resource="" url=""> <property name="" value=""/> </properties> <settings> <setting name="" value=""/> </settings> <typeAliases> <typeAlias alias="" type=""/> <package name=""/> </typeAliases> <typeHandlers> <typeHandler handler="" javaType="" jdbcType=""/> <package name=""/> </typeHandlers> <objectFactory type=""> <property name="" value=""/> </objectFactory> <objectWrapperFactory type=""/> <reflectorFactory type=""/> <plugins> <plugin interceptor=""> <property name="" value=""/> </plugin> </plugins> <environments default=""> <environment id=""> <transactionManager type=""> <property name="" value=""/> </transactionManager> <dataSource type=""> <property name="" value=""/> </dataSource> </environment> </environments> <databaseIdProvider type=""> <property name="" value=""/> </databaseIdProvider> <mappers> <mapper class="" resource="" url=""/> <package name=""/> </mappers> </configuration>