How to get the group name from this interface ISchemaModelGroupPtr ?
-
Tuesday, October 09, 2012 1:02 PM
Microsoft Windows Vista, VS 2010, MSXML 6
Hello,
I am having a hard time trying to return the name or ID of an object from ISchemaModelGroupPtr. I tried those alternatives (pGroup is an instance of ISchemaModelGroupPtr):
BSTR bstrGrpName = NULL; pGroup->get_name(&bstrGrpName); string strGname = BStrToStr(bstrGrpName); strGname = BStrToStr(pGroup->name); strGname = BStrToStr(pGroup->Getid()); strGname = BStrToStr(pGroup->id);
All of these alternatives returned an empty string. I had a look at the SOM reference in MSXML MSDN, but it doesn't seem that the property name exists for this interface, neither the method Getname, even if the call to both compiles successfully.
Does anyone have an idea about this matter? Is it possible to get the name of a Model Group in SOM?
Thanks & Regards,
Hajer
the world is mine
All Replies
-
Tuesday, October 09, 2012 5:21 PM
I don't code with C++ so I can't help with that but using JScript (where admittedly using SOM is much easier as you automatically get the all properties) the following sample works for me:
var schemaCache = new ActiveXObject('Msxml2.XMLSchemaCache.6.0') schemaCache.validateOnLoad = true; schemaCache.add('', 'test2012100901.xsd') var schema = schemaCache.getSchema(''); var modelGroup = schema.modelGroups.item(0); WScript.Echo(modelGroup.name);With the schema 'test2012100901.xsd' being
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:group name="m1"> <xs:sequence> <xs:element name="foo" type="xs:string"/> </xs:sequence> </xs:group> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:group ref="m1"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
the output is "m1" so the model group is in the SOM and its name property can be accessed and read out. How that translates into C++ code is another issue, perhaps someone else can help with that, if above sample does not help you identify the problem with your current approach.
MVP Data Platform Development My blog

