[xsd-users] Re: solution to the visitor custom function? and regex or custom script?

giuseppe ferrari giuseppe500 at yahoo.it
Sun Jul 14 23:48:58 EDT 2013


hello. I have a new problem with the generated tree with xsd.exe and the Wrapper template (for insert custom functions on the wrapper template).
The problem is, as you already saw the constructors.
I get this error for example:

Error    42    error C2661: 'xml_schema::Wrapper<T>::Wrapper' : no overloaded function takes 3 arguments    c:\ifc\dllifc\ifc\ifc2x3.cxx    141383    dllIfc    1

[code]
 base_IfcGeometricRepresentationItem::
      base_IfcGeometricRepresentationItem (const ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem& _xsd_IfcRepresentationItem_base)
      : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem (_xsd_IfcRepresentationItem_base)
      {
      }

      base_IfcGeometricRepresentationItem::
      base_IfcGeometricRepresentationItem ()
      : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem ()
      {
      }

      base_IfcGeometricRepresentationItem::
      base_IfcGeometricRepresentationItem (const base_IfcGeometricRepresentationItem& x,
                                           ::xml_schema::flags f,
                                           ::xml_schema::container* c)
      : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem (x, f, c) //ERROR
      {
      }

      base_IfcGeometricRepresentationItem::
      base_IfcGeometricRepresentationItem (const ::xercesc::DOMElement& e,
                                           ::xml_schema::flags f,
                                           ::xml_schema::container* c)
      : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem (e, f, c)
      {
      }

      base_IfcGeometricRepresentationItem* base_IfcGeometricRepresentationItem::
      _clone (::xml_schema::flags f,
              ::xml_schema::container* c) const
      {
        return new class base_IfcGeometricRepresentationItem (*this, f, c);
      }

      base_IfcGeometricRepresentationItem::
      ~base_IfcGeometricRepresentationItem ()
      {
      }
[/code]

      base_IfcGeometricRepresentationItem::
      base_IfcGeometricRepresentationItem (const base_IfcGeometricRepresentationItem& x,
                                           ::xml_schema::flags f,
                                           ::xml_schema::container* c)
      : ::ifcXML::IFC2x3::FINAL::IfcRepresentationItem (x, f, c) //ERROR
      {
      }


i saw that there are custom option for the constructors in xsd.exe and i use --generate-default-ctor in the hope of construct all with the default constructor, but it's not sufficent, have you another advice for me?
Is a solution ,remove all the constructors and leave only the default constructor?

sorry if I ask again , but i ask only for an advice then i go ahead alone.

thanks.




________________________________
 Da: giuseppe ferrari <giuseppe500 at yahoo.it>
A: "xsd-users at codesynthesis.com" <xsd-users at codesynthesis.com> 
Inviato: Domenica 7 Luglio 2013 15:12
Oggetto: solution to the visitor custom function? and regex or custom script?
 


hello.
I have a partial solution from your advice that creates a template wrapper  in which implement custom functions.
this is an example of an xsd script that create the forward reference to the custom Wrapper for one type
:
xsd cxx-tree --custom-type contact="xml_schema::CustomWrapper<base_contact>/base_contact" --output-dir ifc contacts.xsd

the solution is partial because i have an xsd(ifc.xsd, an architectural format) with more than 2000 classes and i must create a script or something that change this line:

contact="xml_schema::CustomWrapper<base_contact>/base_contact"

in base of the type for each xsd type, and i don't know how.
I see in the documentation that i can extract the list of the types of the xsd(is true?).
a python script or c script is the only solution? Or
 I can i do something with the regex?


after that ,i can implement and insert the CustomWrapper in the xsd_schema namespace of the generated code:

template < class T >
    class CustomWrapper : public T
    { 
    public:        
    CustomWrapper (const ::xercesc::DOMElement& e,
                  ::xml_schema::flags f = 0,
                  ::xml_schema::container* c = 0): T (e, f, c){};

    CustomWrapper (const T& x,
                  ::xml_schema::flags f = 0,
                 
 ::xml_schema::container* c = 0): T (x, f, c){};
        void print(){
        
        
            std::string email= this->email();

            cout << email.c_str();
        };
    };

and , the generated forward reference is like this:

namespace contacts
{
  class base_contact;
  typedef xml_schema::CustomWrapper<base_contact> contact;
  class catalog;
}

now i can call the custom function:

int
main (int argc, char* argv[])
{
  using namespace contacts;

  std::auto_ptr<catalog> c (catalog_ ("contacts.xml"));

  for (catalog::contact_iterator i (c->contact ().begin
 ());
       i != c->contact ().end ();   i)
  {
      (*i).print();
  }
}

the only problem now is the const/no const iterator and custom member function.
this partial solution Is like your advice?
may be correct ?
and...for create the same things for all the classes of the xsd?
thanks.


More information about the xsd-users mailing list