[xsde-users] Get the element name

Boris Kolpackov boris at codesynthesis.com
Wed Sep 17 06:29:45 EDT 2008


Hi Khuong,

Khuong Nguyen Thi Lien <ntlkhuong at tma.com.vn> writes:

> Thanks for your response, instead of using a string member variable to store
> the name, I would like to use the const char* to point to the name array as
> the way to save space for my classes and we only use in the callback and
> then no use anymore. So is there is there any risk by using this way?

This will work in the current implementation though the char array 
returned by n.data() may not be 0-terminated in the general case
(e.g., in the future we may add another XML parser to XSD/e which
may not pass element names as 0-terminated strings to avoid copying).

If you want your code to work in the general case, you will need
to also store the size:

currentElementName     =  n.data();
currentElementNameSize =  n.size();

And then:

slot->setName(currentElementName, currentElementNameSize);

Boris



More information about the xsde-users mailing list