[xsde-users] xs:any and xs:anyAttribute

Jonathan Haws Jonathan.Haws at sdl.usu.edu
Thu Dec 29 18:45:00 EST 2011


I tried the following rule in my makefile:

CoT_%.hxx CoT_%.cxx \
CoT_%-pskel.hxx CoT_%-pskel.cxx \
CoT_%-pimpl.hxx CoT_%-pimpl.cxx \
CoT_%-sskel.hxx CoT_%-sskel.cxx \
CoT_%-simpl.hxx CoT_%-simpl.cxx: CoT_%.xsd
	xsde cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
	--generate-parser --generate-serializer --generate-aggregate \
	--reserved-name major=cotmajor --reserved-name minor=cotminor \
	--namespace-map http://www.w3.org/2001/XMLSchema=$(shell echo $< | cut -d'.' -f1)::xml_schema $<

The sub-schemas build okay, but the sensor and image schemas still conflict.  I have found that the --namespace-map option puts all the base types in their own namespace, but the top level elements (fov, north, vfov, etc.) are still in the top-level namespace.  Here a piece of the generated code:

namespace CoT_sensor
{
  namespace xml_schema
  {
    using ::xsde::cxx::hybrid::any_type;
    typedef ::std::string any_simple_type;

    typedef signed char byte;
    using ::xsde::cxx::hybrid::byte_base;

    typedef unsigned char unsigned_byte;
    using ::xsde::cxx::hybrid::unsigned_byte_base;

    typedef short short_;
    using ::xsde::cxx::hybrid::short_base;

    typedef unsigned short unsigned_short;
    using ::xsde::cxx::hybrid::unsigned_short_base;

    typedef int int_;
    using ::xsde::cxx::hybrid::int_base;

    typedef unsigned int unsigned_int;
    using ::xsde::cxx::hybrid::unsigned_int_base;

    typedef long long long_;
    using ::xsde::cxx::hybrid::long_base;

    typedef unsigned long long unsigned_long;
    using ::xsde::cxx::hybrid::unsigned_long_base;

    typedef long integer;
    using ::xsde::cxx::hybrid::integer_base;

    typedef long non_positive_integer;
    using ::xsde::cxx::hybrid::non_positive_integer_base;

    typedef unsigned long non_negative_integer;
    using ::xsde::cxx::hybrid::non_negative_integer_base;

    typedef unsigned long positive_integer;
    using ::xsde::cxx::hybrid::positive_integer_base;

    typedef long negative_integer;
    using ::xsde::cxx::hybrid::negative_integer_base;

    typedef bool boolean;
    using ::xsde::cxx::hybrid::boolean_base;

    typedef float float_;
    using ::xsde::cxx::hybrid::float_base;

    typedef double double_;
    using ::xsde::cxx::hybrid::double_base;

    typedef double decimal;
    using ::xsde::cxx::hybrid::decimal_base;

    typedef ::std::string string;

    typedef ::std::string normalized_string;

    typedef ::std::string token;

    typedef ::std::string name;

    typedef ::std::string nmtoken;

    typedef ::xsde::cxx::string_sequence nmtokens;

    typedef ::std::string ncname;

    typedef ::std::string language;

    typedef ::std::string id;

    typedef ::std::string idref;

    typedef ::xsde::cxx::string_sequence idrefs;

    typedef ::std::string uri;

    using ::xsde::cxx::qname;

    using ::xsde::cxx::buffer;
    typedef ::xsde::cxx::buffer base64_binary;
    typedef ::xsde::cxx::buffer hex_binary;

    using ::xsde::cxx::time_zone;
    using ::xsde::cxx::date;
    using ::xsde::cxx::date_time;
    using ::xsde::cxx::duration;
    using ::xsde::cxx::gday;
    using ::xsde::cxx::gmonth;
    using ::xsde::cxx::gmonth_day;
    using ::xsde::cxx::gyear;
    using ::xsde::cxx::gyear_month;
    using ::xsde::cxx::time;

    using ::xsde::cxx::hybrid::pod_sequence;
    using ::xsde::cxx::hybrid::fix_sequence;
    using ::xsde::cxx::hybrid::var_sequence;
    using ::xsde::cxx::string_sequence;
    using ::xsde::cxx::hybrid::data_sequence;
  }
}

All the xsde stuff is put in there, but that is not what is conflicting.  It is the class definitions for the elements/attributes that get defined after this block that are conflicting.

Any thoughts?  Am I using the option wrong?  What I want is to get everything that is generated by the xsde call to be wrapped in a separate namespace.  Can that be done?

Thanks!

Jonathan


-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Thursday, December 29, 2011 07:22
To: Jonathan Haws
Cc: xsde-users at codesynthesis.com
Subject: Re: [xsde-users] xs:any and xs:anyAttribute

Hi Jonathan,

Jonathan Haws <Jonathan.Haws at sdl.usu.edu> writes:
 
> My next question is how can I deal with name conflicts between two 
> sub-schemas?  For example, I have two sub-schemas; one called image 
> and one called sensor. Both define a field of view (fov) attribute.
> When I try to link both of those sub-schemas into my test application, 
> I get "multiple definition" errors.  Can this be avoided (i.e. can I 
> provide a way to ensure that the symbol names are unique)?  Ideally I 
> would have something like sensor_fov_pimpl::pre() and
> image_fov_pimpl::pre() instead of just fov_pimpl::pre() for both 
> schemas.  Can this be done?

You can use the --namespace-map XSD/e option[1] to place the generated code for each sub-schemas into a separate C++ namespace. The names then could be: sensor::fov_pimpl and image::fov_pimpl.

[1] http://www.codesynthesis.com/projects/xsde/documentation/xsde.xhtml

Boris



More information about the xsde-users mailing list