[xsd-users] Re: Trying to generate a WSDL parser using xsd code synthesis

Stefan Pantos d922qg at me.com
Sun Mar 11 03:51:14 EDT 2012


Ah, I worked it out! There are two things wrong. Firstly, in this version I forgot to make line 4 'definitions = wsdl::definitions(inputfile, ::xml_schema::flags::keep_dom);' and line 12 should have been made a reference to the sequence.

I still don't understand all the validation errors, if anyone is able to enlighten me and I'm still wondering what the best way is to go about parsing XSD files for my own use.

Thanks,
Stefan

On 10 Mar 2012, at 19:07, Stefan Pantos wrote:

> Hi,
>   I don't have much experience with xsd so I'm probably being stupid. I was wanting to try and create a WSDL parser using XSD Code Synthesis for a toy project. At the moment all I want to do is output the different parts of the WSDL (messages, types, bindings etc) but I'm falling at the first hurdles.
> 
> Some of this is probably irrelevant  but I'm putting in as much as I can think of just in case.
> 
> So I ran xsd ('xsd cxx-tree --generate-wildcard wsdl.xsd') to generate the wsdl.cxx and wsdl.hxx files. the wsdl.xsd file is from http://schemas.xmlsoap.org/wsdl/ . The test file I'm using is Example 1 from http://www.w3.org/TR/wsdl .
> 
> My very simple code is:
> 
>     1	    ::std::auto_ptr< ::wsdl::tDefinitions > definitions;
>     2	    try
>     3	    {
>     4	        definitions = wsdl::definitions(inputfile);
>     5	    }
>     6	    catch (const xsd::cxx::tree::exception<char>& e) {
>     7	        cout << "Error " << e << endl;
>     8	        return 1;
>     9	    }
>    10	    if (definitions.get() != NULL)
>    11	    {
>    12	        ::wsdl::tDefinitions::types_sequence types = definitions->types();
>    13	        for (::wsdl::tDefinitions::types_const_iterator type = types.begin();
>    14	             type != types.end();
>    15	             ++type)
>    16	         {
>    17	             cout << type->_node()->getNodeName() << endl;
>    18	         }
>    19	    }
> 
> 
> It compile without a problem but when I run it against my test file I get lots of errors which are like:
> Error test.wsdl:8:46 error: no declaration found for element 'definitions'
> 
> So I switched of the validation off, this then causes a bad access signal at line 17. I'm using xsd-3.3.0-i686-macosx and xerces-c-3.1.1 in case this might have some bearing on the problem.
> 
> What am I doing wrong?
> 
> If it is some ridicules error which I've made and it is possible, I will want to try and parse the XSD xml in the type section. I had even more fun trying to do something with this because of the recursive nature of it's definition. Should I just give up on this or should this be possible too?
> 
> Thanks,
> Stefan
> 
> 



More information about the xsd-users mailing list