Patch smartasn1 version master
authorEbersold <aebersol@n3150.home>
Sun, 26 Dec 2021 13:04:47 +0000 (14:04 +0100)
committerEbersold <aebersol@n3150.home>
Sun, 26 Dec 2021 13:04:47 +0000 (14:04 +0100)
CMakeLists.txt
libxsd/include/xmlparser.h
libxsd/src/CMakeLists.txt
xsd2cpp-gen.xsl
xsd2cpp-tree-hdr-setget.xsl
xsd2cpp-tree-header.xsl
xsd2cpp-tree-src-serialize.xsl
xsd2cpp-tree.xsl

index 1ad5587b8c62db423f84147165ba6729c782d0c9..12cc8934d6b49b5d66e768d0f6cc9633faf57755 100644 (file)
@@ -1,8 +1,9 @@
 PROJECT(xml-t)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
-SET(WITH_XSD_TOOL FALSE CACHE TYPE BOOL)
-SET(WITH_XSD_TOOL_TESTS OFF CACHE TYPE BOOL)
+SET(WITH_XSD_TOOL ON CACHE   BOOL "Set With XSD Tools")
+
+SET(WITH_XSD_TOOL_TESTS OFF CACHE BOOL "Activate Tests for xsd tools ")
 
 
 IF (WITH_XSD_TOOL)
index 8f39593757397015be79b23255fb1239530c3f8f..4183d9e2a437c3faf5d281d5e43d2aba1055ce38 100644 (file)
@@ -20,53 +20,59 @@ namespace xml {
       public:
         parser() : m_parser(NULL) {}
         //
-        void onStartElement(const CML_Char *name,const XML_Char **attr)
+        void onStartElement(const XML_Char *name,const XML_Char **attr)
         {
-          T *_cls = dynamic_cast< T *>(this);
+          T *_cls = static_cast< T *>(this);
           if (_cls)
            _cls->onStartElement(name,attr);
         }
         //
         void onEndElement(const XML_Char *name)
         {
-             T *_cls = dynamic_cast< T *>(this);
+             T *_cls = static_cast< T *>(this);
              if (_cls)
-                 _cls->onEndElement(name,attr);
+                 _cls->onEndElement(name);
         }
         //
         void onCharacters(const XML_Char *name,size_t sz)
         {
-             T *_cls = dynamic_cast< T *>(this);
+             T *_cls = static_cast< T *>(this);
              if (_cls)
                  _cls->onCharacters(name,sz);
         }
 
         void parse(std::istream &is)
         {
-                void *buf = NULL;
-                m_parser = XML_ParserCreateNS(0,XML_Char(' '));
-                
-                parser_init();
-                
-                do 
+            XML_Status status;
+            void *buf = NULL;
+            m_parser = XML_ParserCreateNS(0,XML_Char(' '));
+            
+            parser_init();
+            
+            do 
+            {
+                buf = XML_GetBuffer(m_parser,XML_BUFFER_SIZE); 
+                if (buf == NULL) 
                 {
-                    buf = XML_GetBuffer(m_parser,XML_BUFFER_SIZE); 
-                    
-                    is.read(buf,XML_BUFFER_SIZE);
-                    
-                    if (is.bad() || (is.fail() && !is.eof()))
-                    {
-                        break; /* End of parsing */
-                    }
-                    if (XML_Parse ( m_parser,buf,is.gcount(),is.eof()) == XML_STATUS_ERROR)
-                    {
-                        break;
-                    }
-                } 
-                while (! is.eof());
+                    std::cerr<<"parse: Failed get Buffer "<<std::endl;
+                }
+                is.read((char *)buf,XML_BUFFER_SIZE);
                 
-                parser_clear();
-            }
+                if (is.bad() || (is.fail() && !is.eof()))
+                {
+                    std::cout<<"parse End or eof"<<std::endl;
+                    break; /* End of parsing */
+                }
+                if ( (status = XML_ParseBuffer ( m_parser,is.gcount(),is.eof())) == XML_STATUS_ERROR)
+                {
+                    std::cout<<"Failed parse buffer read:"<<is.gcount()<<" Eof: "<<is.eof()<<" Satus="<<status<< std::endl;
+                    std::cout<<"Buf = "<<(char *)buf<<std::endl;
+                    break;
+                }
+            } 
+            while (! is.eof());
+            
+            parser_clear();
         }
         //
         void parse(const std::string &str);
@@ -75,18 +81,22 @@ namespace xml {
          * during template instanciation
          *
          */
-        static void XMLCALL startElement_glb(void *user_data, const XML_Char *,const XML_Char **attr)
+        static void XMLCALL startElement_glb(void *user_data, const XML_Char *ns,const XML_Char **attr)
         {
-            parser &doc = (*reinterpret_cast<parser *>(d));
-            doc.startElement(ns,attr);
+            parser &doc = (*reinterpret_cast<parser *>(user_data));
+            doc.onStartElement(ns,attr);
         }
         
         static void XMLCALL endElement_glb(void *user_data,const XML_Char *name)
         {
+            parser &doc = (*reinterpret_cast<parser *>(user_data));
+            doc.onEndElement(name);
         }
         
         static void XMLCALL characters_glb(void *user_data,const XML_Char *ns,int dt)
         {
+            parser &doc = (*reinterpret_cast<parser *>(user_data));
+            doc.onCharacters(ns,dt);
         }
         
         static void XMLCALL startNamespace_glb(void *user_data, const XML_Char *prefix,const XML_Char *uri)
@@ -103,7 +113,7 @@ namespace xml {
         {
             XML_SetUserData(m_parser,this);
             
-            XML_SetStartElementHandler(m_parser,startElement_glb);
+            XML_SetStartElementHandler(m_parser,parser<T>::startElement_glb);
             
             XML_SetEndElementHandler(m_parser,endElement_glb);
             
@@ -123,10 +133,17 @@ namespace xml {
             XML_SetNamespaceDeclHandler(m_parser,0,0);
         }
 
+        bool split_name(const XML_Char *name, std::string &_n,std::string &ns)
+        {
+            char *sp = strchr(const_cast<char *>(name),' ');
+            ns = std::string(name,sp-name);
+            sp++;
+            _n = std::string(sp);
+            return true;
+        }
+
          protected:
-             XML_Parser *m_parser;
-          };
-      }
+             XML_Parser m_parser;
     };
 
 
@@ -134,11 +151,11 @@ namespace xml {
      *
      *
      */
-    class parserImpl : parser<ParserImpl>
+    class parserImpl : parser<parserImpl>
     {
         public:
             parserImpl() {};
-            virtual void onStartElement(const CML_Char *name,const XML_Char **attr)
+            virtual void onStartElement(const XML_Char *name,const XML_Char **attr)
             {
             }
             virtual void onEndElement(const XML_Char *name)
index 424330b3bf71a496efd6f293f2d1f798fd79c4df..6bcecdeb17dc352129595f7a4868ff07feceafad 100644 (file)
@@ -2,8 +2,11 @@ PROJECT(libxsd)
 
 INCLUDE_DIRECTORIES(${libxsd_SOURCE_DIR}/../include)
 INCLUDE_DIRECTORIES(/usr/local/include)
+# Check with BOOTSTRAP_expat too
+IF(NOT WIN32)
+  FIND_PACKAGE(EXPAT REQUIRED)
+ENDIF(NOT WIN32)
 
-FIND_PACKAGE(EXPAT REQUIRED)
 INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR})
 ADD_LIBRARY(libxsd STATIC elements.cpp parser.cpp document_expat.cpp)
 EXPORT(TARGETS libxsd FILE libxsdLibraries.cmake)
@@ -48,7 +51,7 @@ INSTALL(FILES
         ${libxsd_SOURCE_DIR}/../include/xsd/parser/parser.h
         ${libxsd_SOURCE_DIR}/../include/xsd/parser/elements.h
         ${libxsd_SOURCE_DIR}/../include/xsd/parser/document.h
-        ${libxsd_SOURCE_DIR}/../include/xsd/parser/xml-schema.h
+#        ${libxsd_SOURCE_DIR}/../include/xsd/parser/xml-schema.h
         DESTINATION include/xsd/parser
         COMPONENT   Headers
         )
index 586c7d361d8b5affe574a4bb5311f99e2025c7e3..54110cdf7cba293875e37dc72329c8dfc25c444b 100644 (file)
       <xsl:value-of select='concat("std::vector&lt;",$name,"_sptr&gt; ",$name,"_sequence;&#10;")'/>
     </xsl:template>
 
+  <!-- 
+  ***
+  *** gen-tree-hdr-type-member-set
+  ***
+     Here, I should put the prototype of 
+  -->
+    <xsl:template match='xsd:attribute[@name and @type]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:if test='$debug-comment="yes"'>
+          <xsl:text>&INDENT2;/* gen-tree-hdr-type-member-set </xsl:text>
+          <xsl:value-of select='concat(name(.)," @name",@name," ",@type," */&#10;")'/>
+      </xsl:if>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:attribute[@ref]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:if test='$debug-comment="yes"'>
+          <xsl:text>&INDENT2;/* gen-tree-hdr-type-member-set </xsl:text>
+          <xsl:value-of select='concat(name(.)," @ref",@ref," */&#10;")'/>
+      </xsl:if>
+      <!-- 
+        Attributes don't have min or maxOccurs. They are optional, required or prohibited
+      -->
+      <xsl:choose>
+          <xsl:when test='@use and @use="prohibited"'>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='@use and @use="required"'>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_optional &amp;v);&#10;") '/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:attribute[@name and not(@type)]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:if test='$debug-comment="yes"'>
+          <xsl:text>&INDENT2;/* gen-tree-hdr-type-member-set </xsl:text>
+          <xsl:value-of select='concat(name(.)," @name=",@name," no type */&#10;")'/>
+      </xsl:if>
+      <!--<xsl:text>&#10;&INDENT2;void&INDENT2;attr_</xsl:text>
+      <xsl:value-of select='concat($name,"(",$name,"_attr_type &amp;v) ;&#10;")'/>
+      -->
+      <xsl:choose>
+          <xsl:when test='@use and @use="prohibited"'>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='@use and @use="required"'>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_attr_type &amp;v);&#10;") '/>
+          </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_optional &amp;v);&#10;") '/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:element[@ref]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:variable name='local-name'>
+        <xsl:choose>
+          <xsl:when test="contains(@ref,':')"><xsl:value-of select="substring-after(@ref,':')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="@ref"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-set xsd:element </xsl:text>
+      <xsl:value-of select='concat("name=",$name," @ref=",@ref,"  no type and  abstract")'/>
+      <xsl:text>*/&#10;</xsl:text>
+      <xsl:choose>
+          <xsl:when test='$maxOccurs="unbounded"'>
+              <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs>1'>
+            <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs=1'>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_type &amp;v) ;&#10;")'/>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_sptr &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ;&#10;") '/>
+          </xsl:when>
+        <xsl:otherwise>
+          <xsl:message terminate="yes"><xsl:value-of select='$name'/></xsl:message>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+    <!-- Need to be implemented 
+         because of abstract attribute, the generation of the classes is a bit more complicated.
+    -->
+    <xsl:template match='xsd:element[@name and not(@type) and @abstract and @abstract="true"]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='baseclass'></xsl:param>
+    <xsl:variable name='local-name'>
+        <xsl:choose>
+            <xsl:when test="contains(@name,':')"><xsl:value-of select="substring-after(@name,':')"/></xsl:when>
+            <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:variable>
+      <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-set xsd:element </xsl:text>
+      <xsl:value-of select='concat("@name=",@name,"  no type and  abstract")'/>
+      <xsl:text>*/&#10;</xsl:text>
+      <!-- does not work
+      -->
+      <xsl:apply-templates select='/xsd:schema/xsd:element[@equivClass=$local-name]' mode='gen-tree-hdr-type-member-set'>
+          <xsl:with-param name='name' select="$name"></xsl:with-param>
+          <xsl:with-param name='maxOccurs' select="$maxOccurs"></xsl:with-param>
+          <xsl:with-param name='baseclass'>
+              <xsl:choose>
+                  <xsl:when test='$baseclass=""'><xsl:value-of select='$name'/></xsl:when>
+                  <xsl:otherwise><xsl:value-of select='$baseclass'/></xsl:otherwise>
+              </xsl:choose>
+          </xsl:with-param>
+      </xsl:apply-templates>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:element[@name and not(@type) and not(@abstract)]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='baseclass'></xsl:param>
+      <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-set xsd:element </xsl:text>
+      <xsl:value-of select='concat("@name=",@name," no type and not abstract")'/>
+      <xsl:text>*/&#10;</xsl:text>
+      <xsl:choose>
+          <xsl:when test='$maxOccurs="unbounded"'>
+              <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs>1'>
+            <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs=1'>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_type &amp;v) ;&#10;")'/>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_sptr &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ;&#10;") '/>
+          </xsl:when>
+        <xsl:otherwise>
+          <xsl:message terminate="yes"><xsl:value-of select='$name'/></xsl:message>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+    
+    <!-- -->
+    <xsl:template match='xsd:element[@name and @type]' mode='gen-tree-hdr-type-member-set'>
+      <xsl:param name='maxOccurs'/>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='baseclass'></xsl:param>
+      <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-set xsd:element </xsl:text>
+      <xsl:value-of select='concat("@name=",@name," @type=",@type," @equivClass=",@equivClass," maxOccurs=",$maxOccurs)'/>
+      <xsl:text>*/&#10;</xsl:text>
+      <xsl:choose>
+          <xsl:when test='$baseclass'>
+            <xsl:variable name='cpp_type'>
+              <xsl:apply-templates select='@type' mode='restriction-base'/>
+            </xsl:variable>
+            <xsl:variable name='lcpp'><xsl:apply-templates select='@name' mode='normalize-name'/> </xsl:variable>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$lcpp,"_sptr &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$lcpp,"_type &amp;v) ;&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs="unbounded"'>
+              <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs>1'>
+            <xsl:text>&INDENT2;void&#10;&INDENT2;</xsl:text>
+            <xsl:value-of select='concat($name,"(const ",$name,"_sequence &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &amp;v);&#10;") '/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &amp;v);&#10;") '/>
+          </xsl:when>
+          <xsl:when test='$maxOccurs=1'>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_type &amp;v) ;&#10;")'/>
+            <xsl:text>&INDENT2;void </xsl:text>
+            <xsl:value-of select='concat($name,"(",$eltype,"_sptr &amp;v) ;&#10;")'/>
+            <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ;&#10;") '/>
+          </xsl:when>
+        <xsl:otherwise>
+          <xsl:message terminate="yes"><xsl:value-of select='$name'/></xsl:message>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+  <!-- 
+  ***
+  *** gen-tree-hdr-type-member-get
+  ***
+     Here, I should put the prototype of 
+  -->
+    <xsl:template match='xsd:attribute[@name and @type]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @name=",@name," @type=",@type,"  */&#10;")'/>
+      </xsl:if>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:attribute[@ref]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:param name='name'/>
+      <xsl:param name='eltype'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @ref=",@ref,"  */&#10;")'/>
+      </xsl:if>
+      <xsl:choose>
+          <xsl:when test='@use and @use="prohibited"'>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select='concat("&INDENT2;",$eltype,"&#10;&INDENT2;attr_",$name,"(void);&#10;") '/>
+          </xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:attribute[@name and not(@type)]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @name=",@name," no type */&#10;")'/>
+      </xsl:if>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:element[@name and @type]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @ref=",@ref,"  */&#10;")'/>
+      </xsl:if>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:element[@name and not(@type)]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @ref=",@ref,"  */&#10;")'/>
+      </xsl:if>
+    </xsl:template>
+    <!-- -->
+    <xsl:template match='xsd:element[@ref]' mode='gen-tree-hdr-type-member-get'>
+      <xsl:param name='nname'/>
+      <xsl:param name='cpp_type'/>
+      <xsl:param name='maxOccurs'/>
+      <xsl:variable name="ns_type">
+          <xsl:apply-templates select="@ref" mode='namespace-uri-of-qname'/>
+      </xsl:variable>
+      <xsl:variable name='cpp_ns'>
+              <xsl:call-template name='cpp_namespace'>
+                <xsl:with-param name='type' select="$ns_type"/>
+            </xsl:call-template>
+      </xsl:variable>
+      <xsl:if test='$debug-comment="yes"'>
+        <xsl:text>&#10;&INDENT2;/* gen-tree-hdr-type-member-get  </xsl:text>
+        <xsl:value-of select='concat(name(.)," @ref=",@ref," maxOccurs=",$maxOccurs," */&#10;")'/>
+      </xsl:if>
+
+      <xsl:choose>
+        <xsl:when test='($maxOccurs="unbounded")'>
+          <!-- Get function-->
+         <xsl:text>&#10;&INDENT2;</xsl:text>
+         <xsl:value-of select='concat($nname,"_sequence &amp;&#10;")'/>
+         <xsl:value-of select='concat("&INDENT2;",$nname,"( void )  { return me_",$nname," ;};&#10;")'/>
+        </xsl:when>
+        <xsl:when test='(number($maxOccurs)>1)'>
+            <xsl:text>&#10;&INDENT2;//void &INDENT2;</xsl:text>
+          <xsl:value-of select='concat($nname,"(const ",$nname,"_sequence &amp;v) ;&#10;")'/>
+          <!-- Get function-->
+         <xsl:text>&#10;&INDENT2;</xsl:text>
+         <xsl:value-of select='concat($nname,"_sequence &amp;&#10;")'/>
+         <xsl:value-of select='concat("&INDENT2;",$nname,"( void )  { return me_",$nname," ;};&#10;")'/>
+        </xsl:when>
+        <xsl:otherwise>
+          <!-- Get function-->
+          <xsl:text>&#10;&INDENT2;</xsl:text><xsl:value-of
+              select='concat($cpp_type," &amp;&#10;&INDENT2;",$nname,"( void ) ;&#10;")'/>
+        </xsl:otherwise>
+      </xsl:choose>
 
+    </xsl:template>
 
 
   <!-- 
index e9652724de871580b1e6e20b547866f79dc75123..eee0d004b90739174cdcd8015e3cbb3183573662 100644 (file)
             <xsl:apply-templates select='@itemType' mode='restriction-base'/>
     </xsl:variable>
     <xsl:if test='$debug-comment="yes"'>
-      <xsl:text>&INDENT2;/* tree-hdr-setget </xsl:text>
+      <xsl:text>&INDENT;/* tree-hdr-setget </xsl:text>
       <xsl:value-of select='concat(name(.)," @itemType=",@itemType,"*/&#10;")'/>
     </xsl:if>
     <!-- Setter that splist the string -->
     <xsl:text>&INDENT2;</xsl:text><xsl:value-of select='concat($class," &amp; operator=(const std::string &amp;_s);&#10;")'/>
     <!-- Getter that splist the string -->
     <xsl:text>&INDENT2;std::vector&lt;</xsl:text><xsl:value-of select='concat($cpp_type,"&gt; items() {return m_tokens;};&#10;")'/>
-    <xsl:value-of select='concat("&INDENT2;",$cpp_type," operator [](int i) { return m_tokens[i]; } ;&#10;")'/>
   </xsl:template>
 
   <!-- -->
index 0d0bacc9524cf4eb76ade78b444bd40537196a56..1bacba1a1405f39f2d51edc2adbc52a53fe8c032 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE xslt [
 
   <!-- Formating -->
-  <!ENTITY CR "&#10;">
+  <!ENTITY CR "&#xa;">
   <!ENTITY NL "<xsl:text>&#10;</xsl:text>">
   <!ENTITY TAB "&#09;">
   <!ENTITY PV ";">
@@ -34,8 +34,6 @@
   <xsl:import href="xsd2cpp-tree-hdr-mbr-elem.xsl"/>
   <xsl:import href="xsd2cpp-tree-hdr-mbr-attr.xsl"/>
   <xsl:import href="xsd2cpp-tree-hdr-typedef.xsl"/>
-  <xsl:import href="xsd2cpp-tree-hdr-type-mbr-set.xsl" />
-  <xsl:import href="xsd2cpp-tree-hdr-type-mbr-get.xsl" />
   <xsl:import href="xsd2cpp-tree-hdr-setget.xsl"/>
   <xsl:import href="xsd2cpp-tree-hdr-choice-union.xsl"/>
   
     <xsl:param name='class'/>
     <xsl:variable name="po"><xsl:number level="any" from="/" format="1" grouping-size="3"  count='xsd:simpleType|xsd:complexType'/></xsl:variable>
     
-    <xsl:message terminate='no'>xsd2cpp-tree-header: Generate Class: <xsl:value-of select="concat(@name,' ',$class)"/></xsl:message>
+    <xsl:message terminate='no'>wsd2cpp-tree-header: Generate Class: <xsl:value-of select="concat(@name,' ',$class)"/></xsl:message>
     <xsl:if test='local-name(.)="element" or local-name(.)="attribute"'>
         <xsl:message terminate='yes'>ERROR: must not happen <xsl:value-of select="concat(@name,' ',$class)"/></xsl:message>
     </xsl:if>
     <xsl:message terminate='yes'>No yet coded</xsl:message>
   </xsl:template>
 
-  <!-- -->
-  <xsl:template match='xsd:list[not(@itemType)]' mode="parse-tree">
-    <xsl:if test='$debug-comment="yes"'>
-      <xsl:text>&INDENT2;/* parse-tree </xsl:text>
-      <xsl:value-of select='concat(name(.)," */&#10;")'/>
-    </xsl:if>
-    <xsl:variable name='name'>
-        <xsl:apply-templates select='../@name' mode='normalize-name'/>
-    </xsl:variable>
-    <xsl:message terminate='no'>WARNING xsd:list no itemType No yet coded ../@name=<xsl:value-of select='../@name'/></xsl:message>
-    <xsl:text>&INDENT2;/* parse-tree </xsl:text>
-    <xsl:value-of select='concat(name(.)," @itemType=empty")'/>
-    <xsl:text> process list no @itemType */&#10;&#10;</xsl:text>
-    <xsl:apply-templates select="xsd:simpleType" mode='parse-tree'/>
-  </xsl:template>
 
   <!-- -->
-  <xsl:template match='xsd:list[@itemType]' mode="parse-tree">
+  <xsl:template match='xsd:list' mode="parse-tree">
     <xsl:if test='$debug-comment="yes"'>
       <xsl:text>&INDENT2;/* parse-tree </xsl:text>
       <xsl:value-of select='concat(name(.)," */&#10;")'/>
     <xsl:variable name='name'>
         <xsl:apply-templates select='../@name' mode='normalize-name'/>
     </xsl:variable>
-    <xsl:message terminate='no'>WARNING xsd:list @itemType= <xsl:value-of select='@itemType'/> Not yet coded ../@name=<xsl:value-of select='../@name'/></xsl:message>
-    <xsl:variable name='cpp_type'>
-      <xsl:apply-templates select='@itemType' mode='restriction-base'/>
-    </xsl:variable>
-    <xsl:text>&INDENT2;/* parse-tree </xsl:text>
-    <xsl:value-of select='concat(name(.)," @itemType=",@itemType)'/>
-    <xsl:text> should process list */&#10;&#10;</xsl:text>
+      <xsl:message terminate='no'>WARNING xsd:list No yet coded</xsl:message>
+      <xsl:choose>
+          <xsl:when test="@itemType">
+            <xsl:variable name='cpp_type'>
+              <xsl:apply-templates select='@itemType' mode='restriction-base'/>
+            </xsl:variable>
+            <xsl:text>&INDENT2;/* parse-tree LIST should process list */&#10;&INDENT2;</xsl:text>
             <!--
             <xsl:value-of select='concat($name,"_skel &amp; operator =(const ",$cpp_type,"&amp;v) {m_content =v; return *this;};&#10;")'/>
             -->
-    <xsl:text>&INDENT2;typedef std::vector&lt;</xsl:text>
-    <xsl:value-of select='concat($cpp_type,"&gt; ",$name,"_sequence;&#10;")'/>
-    <xsl:text>&INDENT2;typedef std::vector&lt;</xsl:text>
-    <xsl:value-of select='concat($cpp_type,"&gt;::iterator iterator;&#10;")'/>
-    <xsl:text>&INDENT2;typedef std::vector&lt;</xsl:text>
-    <xsl:value-of select='concat($cpp_type,"&gt;::const_iterator const_iterator;&#10;")'/>
-    <xsl:text>&INDENT2;iterator begin()    { return m_tokens.begin(); }&#10;</xsl:text>
-    <xsl:text>&INDENT2;const_iterator begin() const     { return m_tokens.begin(); }&#10;</xsl:text>
-    <xsl:text>&INDENT2;iterator end()      { return m_tokens.end(); }&#10;</xsl:text>
-    <xsl:text>&INDENT2;const_iterator end() const     { return m_tokens.end(); }&#10;</xsl:text>
-    <xsl:text>&INDENT2;size_t size() const { return m_tokens.size(); }&#10;</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+              <xsl:apply-templates select="xsd:simpleType" mode='parse-tree'/>
+          </xsl:otherwise>
+      </xsl:choose>
   </xsl:template>
   <!-- -->
   <xsl:template match='xsd:union' mode="parse-tree">
   </xsl:choose>
 
     <xsl:text>&#10;/* End internal declaration */&#10;</xsl:text>
-    <xsl:text>;&#10;&INDENT;public:&#10;</xsl:text>
+    <xsl:text>;&#10;  public:&#10;</xsl:text>
     <!-- Set function -->
     <xsl:if test='$debug-comment="yes"'>
       <xsl:text>&INDENT2;/* parse-tree </xsl:text>
     </xsl:apply-templates>
     <!-- Get Function -->
     <xsl:text>&INDENT2;</xsl:text>
-    <xsl:apply-templates select='.' mode='ten-tree-hdr-type-member-get'>
+    <xsl:call-template name='get_function'>
       <xsl:with-param name='nname' select='$nname'/>
       <xsl:with-param name='cpp_type'><xsl:value-of select='concat($nname,"_type")'/></xsl:with-param>
       <xsl:with-param name='maxOccurs'>
                       select='$maxOccurs'/></xsl:otherwise>
           </xsl:choose>
       </xsl:with-param>
-    </xsl:apply-templates>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
   </xsl:template>
 
             </xsl:apply-templates>
               <!-- Get function -->
             <xsl:text>&INDENT2;</xsl:text>
-            <xsl:apply-templates select='.' mode='gen-tree-hdr-type-member-get'>
+            <xsl:call-template name='get_function'>
               <xsl:with-param name='nname' select='$nname'/>
               <xsl:with-param name='cpp_type'><xsl:value-of select='concat($nname,"_type")'/></xsl:with-param>
               <xsl:with-param name='maxOccurs'>
                               select='$maxOccurs'/></xsl:otherwise>
                   </xsl:choose>
               </xsl:with-param>
-          </xsl:apply-templates>
+          </xsl:call-template>
       </xsl:when>
       <!-- Case type is not xsd type  -->
       <xsl:when test='$ns_type!="&XSD;"'>
               </xsl:with-param>
           </xsl:apply-templates>
           <!-- Get function -->
-          <xsl:apply-templates select="." mode="gen-tree-hdr-type-member-get">
-            <xsl:with-param name='nname' select='$nname'/>
-            <xsl:with-param name='cpp_type'><xsl:value-of select='$cpp_type'/></xsl:with-param>
-            <xsl:with-param name='maxOccurs'>
-                <xsl:choose>
-                    <xsl:when test='@maxOccurs'><xsl:value-of
-                            select="@maxOccurs"/></xsl:when>
-                    <xsl:otherwise><xsl:value-of
-                            select='$maxOccurs'/></xsl:otherwise>
-                </xsl:choose>
-            </xsl:with-param>
-          </xsl:apply-templates> 
-          
+        <xsl:call-template name='get_function'>
+          <xsl:with-param name='nname' select='$nname'/>
+          <xsl:with-param name='cpp_type'><xsl:value-of select='$cpp_type'/></xsl:with-param>
+          <xsl:with-param name='maxOccurs'>
+              <xsl:choose>
+                  <xsl:when test='@maxOccurs'><xsl:value-of
+                          select="@maxOccurs"/></xsl:when>
+                  <xsl:otherwise><xsl:value-of
+                          select='$maxOccurs'/></xsl:otherwise>
+              </xsl:choose>
+          </xsl:with-param>
+        </xsl:call-template>
           
           <xsl:text>&#10;</xsl:text>
       </xsl:when>
         <xsl:when test='($maxOccurs="unbounded")'>
             <xsl:text>&#10;&INDENT2;//xsd2cpp-tree-header get_function maxOccurs=unbounded</xsl:text>
           <!-- Get function-->
-      <xsl:text>&#10;&INDENT2;</xsl:text><xsl:value-of
-              select='concat($nname,"_sequence &amp;&#10;&INDENT2;",$nname,"( void )  {
-              return (me_",$nname,") ;};&#10;")'/>
+         <xsl:text>&#10;&INDENT2;</xsl:text>
+         <xsl:value-of select='concat($nname,"_sequence &amp;&#10;")'/>
+         <xsl:value-of select='concat("&INDENT2;",$nname,"( void )  { return me_",$nname," ;};&#10;")'/>
         </xsl:when>
         <xsl:when test='(number($maxOccurs)>1)'>
             <xsl:text>&#10;&INDENT2;//void &INDENT2;</xsl:text>
          <xsl:value-of select='concat("&INDENT2;",$nname,"( void )  { return me_",$nname," ;};&#10;")'/>
         </xsl:when>
         <xsl:otherwise>
-            <xsl:text>&#10;&INDENT2;//xsd2cpp-tree-header get_function maxOccurs=1</xsl:text>
           <!-- Get function-->
           <xsl:text>&#10;&INDENT2;</xsl:text><xsl:value-of
               select='concat($cpp_type," &amp;&#10;&INDENT2;",$nname,"( void )  {
index 55d5f0aa07c65e2f264c6936d780937c45760361..764710f8e489bed4d77e5699176a7c4a9c66e120 100644 (file)
       <xsl:value-of select='concat(name(.)," @name=",@name)'/><xsl:text> to be coded&#10;</xsl:text>
     </xsl:if>
   </xsl:template>
-  <!-- xsd:list -->
-  <xsl:template  match='xsd:list[@itemType]' mode="tree-src-serialize">
-    <xsl:variable name='name'>
-        <xsl:apply-templates select='../@name' mode='normalize-name'/>
-    </xsl:variable>
-    <xsl:if test='$debug-comment="yes"'>
-      <xsl:text>&INDENT;// tree-src-serialize </xsl:text>
-      <xsl:value-of select='concat(name(.)," @itemType=",@itemType)'/><xsl:text> to be coded&#10;</xsl:text>
-    </xsl:if>
-    <xsl:text>&INDENT;for(</xsl:text>
-    <xsl:value-of select='concat($name,$cls-tree-suff)'/>
-    <xsl:text>::const_iterator it = obj.begin() ; it != obj.end() ; ++it)</xsl:text>
-    <xsl:text>&INDENT;if (it == obj.begin() ) { os&lt;&lt;(*it); } else </xsl:text>
-    <xsl:text>os&lt;&lt;" "&lt;&lt;(*it);&#10;</xsl:text>
-  </xsl:template>
-  
-  <xsl:template  match='xsd:list[not(@itemType)]' mode="tree-src-serialize">
-    <xsl:if test='$debug-comment="yes"'>
-      <xsl:text>&INDENT;// tree-src-serialize </xsl:text>
-      <xsl:value-of select='concat(name(.)," @itemType=",@itemType)'/><xsl:text> to be coded&#10;</xsl:text>
-    </xsl:if>
+  <!-- -->
+  <xsl:template  match='xsd:list' mode="tree-src-serialize">
       <xsl:text>&INDENT;os&lt;&lt;obj.m_content;&#10;</xsl:text>
   </xsl:template>
   <!-- -->
index b7dc5a26136442bb41ad2973dc6d20645be5b480..d61aaada44a923aff012d4af4ebe12a74c5713f2 100644 (file)
         <!-- Include imports -->
         <xsl:apply-templates select='/xsd:schema/xsd:import' mode='include-tree'/>
         <xsl:text>#include &lt;</xsl:text><xsl:value-of select="concat(substring-before($filename-org,'.xsd'),'.h')"/><xsl:text>&gt;&#10;</xsl:text>
-       <!-- DEBUG MACRO-->
-        <xsl:text>&CR;/* DEBUG MACRO  */&#10;</xsl:text>
-       <xsl:text>#ifdef DEBUG&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG(f) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG_CONSTRUCT(f) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG_CONSTRUCT_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_INFO_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_ERROR_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#else&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG(f) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG_CONSTRUCT(f) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_DEBUG_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_INFO_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#define LOG_ERROR_FMT(f,args...) do {} while (0)&CR;</xsl:text>
-       <xsl:text>#endif&CR;</xsl:text>
-       <xsl:text>&#10;namespace </xsl:text>
+        <xsl:text>&#10;namespace </xsl:text>
         <!--
         <xsl:call-template name='cpp_namespace'>
           <xsl:with-param name='type' select="/xsd:schema/@targetNamespace"/>
           <xsl:with-param name='mode' />
           <xsl:with-param name='indent' select='concat("&INDENT;","")'/>
           <xsl:with-param name='string'>
-              <xsl:text>LOG_DEBUG_CONSTRUCT_FMT("</xsl:text>
-              <xsl:value-of select='concat($class,"::",$class," adresse=%p")'/>
-              <xsl:text>",(void *)this);</xsl:text>
+              <xsl:text>std::cout&lt;&lt;"</xsl:text>
+              <xsl:value-of select='concat($class,"::",$class," adresse=")'/>
+              <xsl:text>"&lt;&lt;this&lt;&lt;"\n";</xsl:text>
       </xsl:with-param>
       </xsl:call-template>
       <xsl:variable name="cparam">
           <xsl:with-param name='mode' />
           <xsl:with-param name='indent' select='concat("&INDENT;","")'/>
           <xsl:with-param name='string'>
-              <xsl:text>LOG_DEBUG_CONSTRUCT_FMT("</xsl:text>
-              <xsl:value-of select='concat($class,"::",$class," copy constructor adresse=%p")'/>
-              <xsl:text>",(void *)this);</xsl:text>
+              <xsl:text>std::cout&lt;&lt;"</xsl:text>
+              <xsl:value-of select='concat($class,"::",$class," const adresse=")'/>
+              <xsl:text>"&lt;&lt;this&lt;&lt;"\n";</xsl:text>
          </xsl:with-param>
       </xsl:call-template>
     <!-- A but lazy ...-->
           <xsl:with-param name='mode' />
           <xsl:with-param name='indent' select='concat("&INDENT;","")'/>
           <xsl:with-param name='string'>
-              <xsl:text>LOG_DEBUG_CONSTRUCT_FMT("</xsl:text>
-              <xsl:value-of select='concat($class,"::~",$class," adresse=%p")'/>
-              <xsl:text>",(void *)this);</xsl:text>
+              <xsl:text>std::cout&lt;&lt;"</xsl:text>
+              <xsl:value-of select='concat($class,"::~",$class," adresse=")'/>
+              <xsl:text>"&lt;&lt;this&lt;&lt;"\n";</xsl:text>
          </xsl:with-param>
       </xsl:call-template>
     <xsl:apply-templates