[xsd-users] assign enumeration to string

Schmilinsky, Remsy Remsy.Schmilinsky at ccra-adrc.gc.ca
Thu Nov 2 16:49:07 EST 2006


Perhaps this is rather a question for a C++ forum, but I wonder if you
can help me put the value of a generated enumeration value in a string,
for instance, a section from my schema is this:


  <!-- Type of request -->
  <xsd:simpleType name="requestType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="transaction"/>
      <xsd:enumeration value="query"/>
    </xsd:restriction>
  </xsd:simpleType>  

How can I assign the generated value corresponding to an
xsd::enumeration to a std::string variable? 

I try to do this in my test file:

// Parse the tree
std::auto_ptr<service::request> s(service::request_(file, 0,
queryProps));
std::string requestType = s->requestType();

of course I get the error:

test.cpp:37: error: conversion from
`xsd::cxx::tree::optional<service::requestType,  false>' to non-scalar
type `std::basic_st
ring<char, std::char_traits<char>, std::allocator<char> >' requested

tnx

Remsy




More information about the xsd-users mailing list