xsd_namespace keyword for thrift
authorMark Slee <mcslee@apache.org>
Wed, 31 Jan 2007 02:08:30 +0000 (02:08 +0000)
committerMark Slee <mcslee@apache.org>
Wed, 31 Jan 2007 02:08:30 +0000 (02:08 +0000)
Summary: So you can Spaceify the Shiznits

Reviewed By: fett

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664959 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_xsd_generator.cc
compiler/cpp/src/parse/t_program.h
compiler/cpp/src/thriftl.ll
compiler/cpp/src/thrifty.yy

index d07be91..757009f 100644 (file)
@@ -110,10 +110,15 @@ void t_xsd_generator::generate_service(t_service* tservice) {
   string f_xsd_name = string(T_XSD_DIR)+"/"+tservice->get_name()+".xsd";
   f_xsd_.open(f_xsd_name.c_str());
 
+  string ns = program_->get_xsd_namespace();
+  if (ns.size() > 0) {
+    ns = " targetNamespace=\"" + ns + "\" xmlns=\"" + ns + "\"";
+  }
+
   // Print the XSD header
   f_xsd_ <<
     "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl <<
-    "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" << endl <<
+    "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" << ns << ">" << endl <<
     endl <<
     "<!-- Yo yo yo, this XSD woz be generated by Thrift. -->" << endl <<
     endl;
index 9a86621..7f7af44 100644 (file)
@@ -130,6 +130,13 @@ class t_program {
     return java_package_;
   }
 
+  void set_xsd_namespace(std::string xsd_namespace) {
+    xsd_namespace_ = xsd_namespace;
+  }
+
+  const std::string& get_xsd_namespace() const {
+    return xsd_namespace_;
+  }
 
  private:
 
@@ -168,6 +175,9 @@ class t_program {
   // Java package
   std::string java_package_;
 
+  // XSD namespace
+  std::string xsd_namespace_;
+
 };
 
 #endif
index 855443b..d54a2ad 100644 (file)
@@ -61,6 +61,7 @@ sliteral      ("'"[^']*"'")
 "php_namespace" { return tok_php_namespace; }
 "xsd_all"       { return tok_xsd_all;       }
 "xsd_optional"  { return tok_xsd_optional;  }
+"xsd_namespace" { return tok_xsd_namespace; }
 "include"       { return tok_include;       }
 
 "void"          { return tok_void;          }
index d8f3435..a90d64b 100644 (file)
@@ -68,6 +68,7 @@ int y_field_val = -1;
 %token tok_java_package
 %token tok_xsd_all
 %token tok_xsd_optional
+%token tok_xsd_namespace
 
 /**
  * Base datatype keywords
@@ -218,6 +219,13 @@ Header:
         g_program->set_java_package($2);
       }
     }
+| tok_xsd_namespace tok_literal
+    {
+      pdebug("Header -> tok_xsd_namespace tok_literal");
+      if (g_parse_mode == PROGRAM) {
+        g_program->set_xsd_namespace($2);
+      }
+    }
 
 Include:
   tok_include tok_literal