[xsd-users] Using a SAX parser in cxx-tree

Ivan Le Lann ivan.lelann at free.fr
Thu Aug 12 06:01:55 EDT 2010


> It seems I overlooked C++/Hybrid.
> I toyed with it, and it looks very promising.

I think I found a problem in XSDe library.
My options are : cxx-hybrid --root-element SKWML --generate-parser --generate-serializer --generate-aggregate.

I fed it with a schema with no namespace :

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="SKWML">
    <xs:complexType>
...


And exspected the following serializing code to work :
(quickly adapted from : xsde-3.1.0-i686-windows\examples\cxx\hybrid\library\driver.cxx)


    SKWML_saggr catalog_s;

    xml_schema::document_simpl doc_s (
      catalog_s.root_serializer (),
      catalog_s.root_namespace (),
      catalog_s.root_name ());

    //doc_s.add_prefix ("lib", "http://www.codesynthesis.com/library");
    //doc_s.add_schema ("http://www.codesynthesis.com/library", "library.xsd");

    catalog_s.pre (*c); 
    std::ofstream ofs ("out.xml");
    doc_s.serialize (ofs);
    catalog_s.post ();


It gave me "illegal namespace name" genx error code.
Looking at xsde-3.1.0-i686-windows\libxsde\xsde\c\genx\genx.c
(line: 841, method: genxDeclareNamespace, code:  "if (uri == NULL || uri[0] == 0)"   )
it seems that the check on namespace argument does not match with calling code.

I modified "genxStartElementLiteral", "genxAddAttributeLiteral", "genxStartAttributeLiteral" :
"if (xmlns)" --> "if (xmlns  && xmlns[0] != 0)" 
This fixed my problem.


Indeed the root namespace in my case is : (in generated file *-simpl.cxx)

const char* SKWML_saggr::
root_namespace ()
{
  return ""; // I tried changing this to NULL : got runtime error
}

Regards,
Ivan.



More information about the xsd-users mailing list