1 29 30 package com.caucho.jaxb; 31 32 import com.caucho.jaxb.skeleton.Skeleton; 33 34 import javax.xml.bind.JAXBException; 35 import javax.xml.stream.XMLStreamException; 36 import javax.xml.stream.XMLStreamWriter; 37 38 41 public class SchemaGenerator { 42 private final JAXBContextImpl _context; 43 44 public SchemaGenerator(JAXBContextImpl context) 45 { 46 _context = context; 47 } 48 49 public void generateWrappedType(XMLStreamWriter out, 50 String wrapperName, Class ... wrappedClasses) 51 throws XMLStreamException, JAXBException 52 { 53 out.writeStartElement("xsd", 54 "complexType", 55 "http://www.w3.org/2001/XMLSchema"); 56 out.writeAttribute("name", wrapperName); 57 58 out.writeStartElement("xsd", 59 "sequence", 60 "http://www.w3.org/2001/XMLSchema"); 61 62 for (Class wrappedClass : wrappedClasses) 63 generateSchemaParticle(out, wrappedClass); 64 65 out.writeEndElement(); 67 out.writeEndElement(); } 69 70 public void generateSchemaParticle(XMLStreamWriter out, Class cl) 71 throws XMLStreamException, JAXBException 72 { 73 Skeleton skeleton = _context.getSkeleton(cl); 74 skeleton.generateSchema(out); 75 } 76 } 77 | Popular Tags |