如何用java创建xml模式
为了自动创建一个xml文件,以便稍后转换为jpa类别,我尝试使用de hyperjaxb3包中的类创建Estrestructure。 这就是我创建对象的方式:
Annotation an = new Annotation();
Appinfo ap= new Appinfo();
en.setName("Entidad");
ap.setContent(en);
an.setContents(ap);
schema1.setAnnotation(an);
然后在控制台(或导出为xml文件)中生成以下行:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:extensionBindingPrefixes="hj orm" xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:tns="http://java.sun.com/xml/ns/jaxb" targetNamespace="http://java.sun.com/xml/ns/jaxb" attributeFormDefault="qualified" elementFormDefault="qualified">
<xsd:annotation>
<xsd:appinfo>
//The Entity object should be generated here, but it does not.
</xsd:appinfo>
</xsd:annotation>
</xsd:schema>
我需要在xsd:appinfo元素中生成一个实体XML元素,如下所示
<xsd:appinfo>
<hj:entity></hj:entity>
</xsd:appinfo>
提前谢谢
共 (0) 个答案