简体   繁体   English

带有枚举的XML模式

[英]XML Schema with enumeration

I am using XJC to create from XML Schema a Jaxb annotated class. 我正在使用XJC从XML Schema创建一个Jaxb注释类。 With

JAXBContext context = JAXBContext.newInstance(SomeClass.class);
Marshaller marshaller = context.createMarshaller();

StringWriter writer = new StringWriter();
marshaller.marshal(cardJob, writer);
String resultString = writer.getBuffer().toString();

I create an xml output string - This works perfect. 我创建一个xml输出字符串-完美的作品。 What I want to achieve is, adding an enum to this class like 我想要实现的是在该类中添加一个枚举,例如

Jan (1, "January"),
Feb (2, "February"),

...

by creating an entry in the xml schema and getting in the end an output like <.January><./January>. 通过在xml模式中创建一个条目并最后获得类似<.January> <./ January>的输出。 Maybe wrong but something like an xml element from an enum entry name. 可能是错误的,但类似于枚举条目名称中的xml元素。

Help would be pretty great, cause I dont get any solution :( 帮助将是非常不错的,因为我没有得到任何解决方案:(

maybe you can build your own ContentHandler org.xml.sax.ContentHandler 也许您可以构建自己的ContentHandler org.xml.sax.ContentHandler

handle the enums and put them into buffer before endDocument 处理枚举并将它们放入endDocument之前的缓冲区中

marshaller.marshal(obj, new yourContentHandler());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM