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)
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);
* 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)
{
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);
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;
};
*
*
*/
- 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)
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)
${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
)
<xsl:value-of select='concat("std::vector<",$name,"_sptr> ",$name,"_sequence; ")'/>
</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," */ ")'/>
+ </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," */ ")'/>
+ </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 &v); ") '/>
+ </xsl:when>
+ <xsl:when test='@use and @use="required"'>
+ <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_optional &v); ") '/>
+ </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 */ ")'/>
+ </xsl:if>
+ <!--<xsl:text> &INDENT2;void&INDENT2;attr_</xsl:text>
+ <xsl:value-of select='concat($name,"(",$name,"_attr_type &v) ; ")'/>
+ -->
+ <xsl:choose>
+ <xsl:when test='@use and @use="prohibited"'>
+ <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='@use and @use="required"'>
+ <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_attr_type &v); ") '/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='concat("&INDENT2;void attr_",$name,"(",$name,"_optional &v); ") '/>
+ </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> &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>*/ </xsl:text>
+ <xsl:choose>
+ <xsl:when test='$maxOccurs="unbounded"'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs>1'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs=1'>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_type &v) ; ")'/>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_sptr &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ; ") '/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-set xsd:element </xsl:text>
+ <xsl:value-of select='concat("@name=",@name," no type and abstract")'/>
+ <xsl:text>*/ </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> &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>*/ </xsl:text>
+ <xsl:choose>
+ <xsl:when test='$maxOccurs="unbounded"'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs>1'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs=1'>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_type &v) ; ")'/>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_sptr &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ; ") '/>
+ </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> &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>*/ </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 &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$lcpp,"_type &v) ; ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs="unbounded"'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs>1'>
+ <xsl:text>&INDENT2;void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($name,"(const ",$name,"_sequence &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_type &v); ") '/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$name,"_sptr &v); ") '/>
+ </xsl:when>
+ <xsl:when test='$maxOccurs=1'>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_type &v) ; ")'/>
+ <xsl:text>&INDENT2;void </xsl:text>
+ <xsl:value-of select='concat($name,"(",$eltype,"_sptr &v) ; ")'/>
+ <xsl:value-of select='concat("&INDENT2;void ",$name,"(",$eltype,"_type *v) ; ") '/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @name=",@name," @type=",@type," */ ")'/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @ref=",@ref," */ ")'/>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test='@use and @use="prohibited"'>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select='concat("&INDENT2;",$eltype," &INDENT2;attr_",$name,"(void); ") '/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @name=",@name," no type */ ")'/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @ref=",@ref," */ ")'/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @ref=",@ref," */ ")'/>
+ </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> &INDENT2;/* gen-tree-hdr-type-member-get </xsl:text>
+ <xsl:value-of select='concat(name(.)," @ref=",@ref," maxOccurs=",$maxOccurs," */ ")'/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test='($maxOccurs="unbounded")'>
+ <!-- Get function-->
+ <xsl:text> &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($nname,"_sequence & ")'/>
+ <xsl:value-of select='concat("&INDENT2;",$nname,"( void ) { return me_",$nname," ;}; ")'/>
+ </xsl:when>
+ <xsl:when test='(number($maxOccurs)>1)'>
+ <xsl:text> &INDENT2;//void &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($nname,"(const ",$nname,"_sequence &v) ; ")'/>
+ <!-- Get function-->
+ <xsl:text> &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($nname,"_sequence & ")'/>
+ <xsl:value-of select='concat("&INDENT2;",$nname,"( void ) { return me_",$nname," ;}; ")'/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- Get function-->
+ <xsl:text> &INDENT2;</xsl:text><xsl:value-of
+ select='concat($cpp_type," & &INDENT2;",$nname,"( void ) ; ")'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
<!--
<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,"*/ ")'/>
</xsl:if>
<!-- Setter that splist the string -->
<xsl:text>&INDENT2;</xsl:text><xsl:value-of select='concat($class," & operator=(const std::string &_s); ")'/>
<!-- Getter that splist the string -->
<xsl:text>&INDENT2;std::vector<</xsl:text><xsl:value-of select='concat($cpp_type,"> items() {return m_tokens;}; ")'/>
- <xsl:value-of select='concat("&INDENT2;",$cpp_type," operator [](int i) { return m_tokens[i]; } ; ")'/>
</xsl:template>
<!-- -->
<!DOCTYPE xslt [
<!-- Formating -->
- <!ENTITY CR " ">
+ <!ENTITY CR "
">
<!ENTITY NL "<xsl:text> </xsl:text>">
<!ENTITY TAB "	">
<!ENTITY PV ";">
<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(.)," */ ")'/>
- </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 */ </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(.)," */ ")'/>
<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 */ </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 */ &INDENT2;</xsl:text>
<!--
<xsl:value-of select='concat($name,"_skel & operator =(const ",$cpp_type,"&v) {m_content =v; return *this;}; ")'/>
-->
- <xsl:text>&INDENT2;typedef std::vector<</xsl:text>
- <xsl:value-of select='concat($cpp_type,"> ",$name,"_sequence; ")'/>
- <xsl:text>&INDENT2;typedef std::vector<</xsl:text>
- <xsl:value-of select='concat($cpp_type,">::iterator iterator; ")'/>
- <xsl:text>&INDENT2;typedef std::vector<</xsl:text>
- <xsl:value-of select='concat($cpp_type,">::const_iterator const_iterator; ")'/>
- <xsl:text>&INDENT2;iterator begin() { return m_tokens.begin(); } </xsl:text>
- <xsl:text>&INDENT2;const_iterator begin() const { return m_tokens.begin(); } </xsl:text>
- <xsl:text>&INDENT2;iterator end() { return m_tokens.end(); } </xsl:text>
- <xsl:text>&INDENT2;const_iterator end() const { return m_tokens.end(); } </xsl:text>
- <xsl:text>&INDENT2;size_t size() const { return m_tokens.size(); } </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> /* End internal declaration */ </xsl:text>
- <xsl:text>; &INDENT;public: </xsl:text>
+ <xsl:text>; public: </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> </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> </xsl:text>
</xsl:when>
<xsl:when test='($maxOccurs="unbounded")'>
<xsl:text> &INDENT2;//xsd2cpp-tree-header get_function maxOccurs=unbounded</xsl:text>
<!-- Get function-->
- <xsl:text> &INDENT2;</xsl:text><xsl:value-of
- select='concat($nname,"_sequence & &INDENT2;",$nname,"( void ) {
- return (me_",$nname,") ;}; ")'/>
+ <xsl:text> &INDENT2;</xsl:text>
+ <xsl:value-of select='concat($nname,"_sequence & ")'/>
+ <xsl:value-of select='concat("&INDENT2;",$nname,"( void ) { return me_",$nname," ;}; ")'/>
</xsl:when>
<xsl:when test='(number($maxOccurs)>1)'>
<xsl:text> &INDENT2;//void &INDENT2;</xsl:text>
<xsl:value-of select='concat("&INDENT2;",$nname,"( void ) { return me_",$nname," ;}; ")'/>
</xsl:when>
<xsl:otherwise>
- <xsl:text> &INDENT2;//xsd2cpp-tree-header get_function maxOccurs=1</xsl:text>
<!-- Get function-->
<xsl:text> &INDENT2;</xsl:text><xsl:value-of
select='concat($cpp_type," & &INDENT2;",$nname,"( void ) {
<xsl:value-of select='concat(name(.)," @name=",@name)'/><xsl:text> to be coded </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 </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<<(*it); } else </xsl:text>
- <xsl:text>os<<" "<<(*it); </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 </xsl:text>
- </xsl:if>
+ <!-- -->
+ <xsl:template match='xsd:list' mode="tree-src-serialize">
<xsl:text>&INDENT;os<<obj.m_content; </xsl:text>
</xsl:template>
<!-- -->
<!-- Include imports -->
<xsl:apply-templates select='/xsd:schema/xsd:import' mode='include-tree'/>
<xsl:text>#include <</xsl:text><xsl:value-of select="concat(substring-before($filename-org,'.xsd'),'.h')"/><xsl:text>> </xsl:text>
- <!-- DEBUG MACRO-->
- <xsl:text>&CR;/* DEBUG MACRO */ </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> namespace </xsl:text>
+ <xsl:text> 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<<"</xsl:text>
+ <xsl:value-of select='concat($class,"::",$class," adresse=")'/>
+ <xsl:text>"<<this<<"\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<<"</xsl:text>
+ <xsl:value-of select='concat($class,"::",$class," const adresse=")'/>
+ <xsl:text>"<<this<<"\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<<"</xsl:text>
+ <xsl:value-of select='concat($class,"::~",$class," adresse=")'/>
+ <xsl:text>"<<this<<"\n";</xsl:text>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates