示例#1
0
 private void assembleXSD(Writer w, Model m, MainInfo main)
     throws IOException, ProcessingException {
   String namespace = main.getAnnotation().targetNamespace();
   w.append(
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
           + "<xsd:schema xmlns=\""
           + namespace
           + "\"\r\n"
           + "	xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:beans=\"http://www.springframework.org/schema/beans\"\r\n"
           + "	targetNamespace=\""
           + namespace
           + "\"\r\n"
           + "	elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\">\r\n"
           + "\r\n"
           + "<!-- Automatically generated by "
           + Schemas.class.getName()
           + ". -->\r\n"
           + "\r\n"
           + "<xsd:import namespace=\"http://www.springframework.org/schema/beans\" schemaLocation=\"http://www.springframework.org/schema/beans/spring-beans-3.1.xsd\" />\r\n"
           + "\r\n"
           + "<xsd:simpleType name=\"spel_number\">\r\n"
           + "    <xsd:restriction base=\"xsd:string\">\r\n"
           + "        <xsd:pattern value=\"-?[0-9]+|\\#\\{.*\\}\"></xsd:pattern>\r\n"
           + "    </xsd:restriction>\r\n"
           + "</xsd:simpleType>\r\n"
           + "\r\n"
           + "<xsd:simpleType name=\"spel_boolean\">\r\n"
           + "    <xsd:restriction base=\"xsd:string\">\r\n"
           + "        <xsd:pattern value=\"[01]|true|false|\\#\\{.*\\}\"></xsd:pattern>\r\n"
           + "    </xsd:restriction>\r\n"
           + "</xsd:simpleType>\r\n\r\n");
   assembleDeclarations(w, m, main);
   w.append("</xsd:schema>");
 }
示例#2
0
  public void writeXSD(Model m) throws IOException {
    try {
      for (MainInfo main : m.getMains()) {
        List<Element> sources = new ArrayList<Element>();
        sources.add(main.getElement());
        sources.addAll(main.getInterceptorElements());

        FileObject o =
            processingEnv
                .getFiler()
                .createResource(
                    StandardLocation.CLASS_OUTPUT,
                    main.getAnnotation().outputPackage(),
                    main.getAnnotation().outputName(),
                    sources.toArray(new Element[0]));
        BufferedWriter bw = new BufferedWriter(o.openWriter());
        try {
          assembleXSD(bw, m, main);
        } finally {
          bw.close();
        }
      }
    } catch (FilerException e) {
      if (e.getMessage().contains("Source file already created")) return;
      throw e;
    }
  }