[xsd-users] AnyType and the extraction of contents

Daniel Kåsa daniel.kaasa at gmail.com
Mon May 11 20:55:37 EDT 2020


Hi Boris,

I did as you asked and fabricated a test from the examples. However, due to
the
complexity of the schemas I am currently working with; I have mocked
a test schema to resemble somewhat the original that I am having issues
with.
The fabricated test works as expected. When I look at the generated code for
both cases, it is clear that I haven't achieved an exact same
representation. *shown below"

I am using the following switches more or less for both cases:
--generate-inline
--generate-serialization
--generate-wildcard
--generate-any-type
--import-maps
--generate-polymorphic
--root-element OM_Observation

Note that we are creating libraries for all our schemas and linking them
together based on their dependencies where GML is one of many. We have added
--generate-any-type to all of them but see no difference for any types.

Snip from the generated "observation.xsd" OGC Observation & Measurements
schema:

---------------------------- snip ------------------------------
// result
//
{
  ::std::unique_ptr< ::xsd::cxx::tree::type > tmp (
    ::xsd::cxx::tree::type_factory_map_instance< 0, char > ().create (
      "result",
      "http://www.opengis.net/om/2.0",
      &::xsd::cxx::tree::factory_impl< result_type >,
      true, true, i, n, f, this));

  if (tmp.get () != 0)
  {
    if (!result_.present ())
    {
      ::std::unique_ptr< result_type > r (
        dynamic_cast< result_type* > (tmp.get ()));

      if (r.get ())
        tmp.release ();
      else
        throw ::xsd::cxx::tree::not_derived< char > ();

      this->result_.set (::std::move (r));
      continue;
    }
  }

---------------------------- snip ------------------------------


Snip from the generated mockup test that works as expected:

---------------------------- snip ------------------------------
// result
//
if (n.name () == "result" && n.namespace_ () == "
http://www.kongsberg.com/observation")
{
  ::std::auto_ptr< result_type > r (
    result_traits::create (i, f | ::xml_schema::flags::extract_content,
this));

  if (!result_.present ())
  {
    this->result_.set (r);
    continue;
  }
}
---------------------------- snip ------------------------------

Daniel


On Mon, May 11, 2020 at 3:06 PM Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Daniel Kĺsa <daniel.kaasa at gmail.com> writes:
>
> > I might not understand fully how to automatically have the generated
> > bindings extract the contents for AnyType. I expected that when parsing
> and
> > passing the dom document, the AnyType elements would contain content and
> > this could be accessible by invoking the dom_content() method, however I
> > experience these to be empty "null_content()". Note that I have include
> the
> > --generate-any-type option when generating the bindings, but this has not
> > apparent effect. Is there something I might not have done correctly?
>
> It sounds like you've taken all the right steps. Can you make sure that
> --generate-any-type is specified when compiling all your schemas (in
> particular, it must be in effect when compiling elements of anyType).
>
> If this does not help, try to come up with a small test (i.e., schema,
> test driver, and an XML file), that reproduces this issue and I will
> take a look.
>


More information about the xsd-users mailing list