[xsd-users] how to access xs:ref="element" target element name

vikas pvssvikas at gmail.com
Mon Aug 27 16:35:38 EDT 2012


Hello Boris,

Thank you very much for your time. Yes we are using substitution groups, I
missed the mentioned part of documentation as I was looking for " xsd:ref "
kind of example. Thanks for mentioning the relevant section. However, the
technique used in that section will be more useful when we have limited
number of derived types.

In my case we have more number of derived types, so we are maintaining
internal map of derived handler objects versus element names, so that xsd
derived object can be interpreted by appropriate handler function.

I was able to get the xml element node name when "keep_dom" flag is used.
can you please help me with information, on when to use NodeName & when to
use LocalName methods? In case of keep_dom usage do i need to take care of
any special object destruction? or is it fine if I can rely on auto_ptr?

auto_ptr<testbed::config::scenario> s( testbed::config::scenario_ (
"UserCreationCheck.xml",
 xml_schema::flags::keep_dom
 )
  );

 wprintf(L"%s \n",s.get()->_node()->getLocalName());

testbed::config::OperationData &opD1 =
*(s.get()->testcases().testcase().begin()->operation().begin());

                wprintf(L"%s \n", opD1._node()->getNodeName() );
wprintf(L"%s \n", opD1._node()->getLocalName());

Thanks,
-Vikas.

On Fri, Aug 24, 2012 at 6:37 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Vikas,
>
> vikas <pvssvikas at gmail.com> writes:
>
> > *Can you please let me know how to access element name of the parsed xml,
> > when reference elements are being used with xsd?*
> >
> > *Sample  xsd:*
> >
> > <OperationList>
> >   <xs:sequence>
> >      <xs:element ref="operation" minOccurs="1"
> >   maxOccurs="unbounded" />
> >   </xs:sequence>
> > </OperationList>
> >
> > *Sample xml:*
> >
> > <OperationList>
> >
> >    <createglobaluser id = 1>
> >    </createglobaluser>
> >
> >    <createlocaluser id = 2>
> >    </createglobaluser>
> >
> > </OperationList>
>
> I am not sure what you are trying to get. Is it "operation"? Or maybe
> "createglobaluser"? Or a value of createglobaluser?
>
> I suspect your schema is using substitution groups. Have you read
> Section 2.11, "Mapping for xsi:type and Substitution Groups" in the
> C++/Tree Mapping User Manual?
>
>
> http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11
>
> Boris
>


More information about the xsd-users mailing list