Good morning,
I'm using Xerces-c-3.1.1 built as a static library on mingw/msys on
Windows Vista.
I succeed on loading a schema grammar from a file and I can list the
schema components but I get the following behaviour:
1) SCHEMA
In the schema there are global element and attribute declarations as well
as their types:
- the (attribute) simple type definition:
<xs:simpleType name="int_0_100_t">
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
- the attribute declaration:
<xs:attribute name="attr_int_0_100" type="int_0_100_t"/>
- the (element) complex type definition:
<xs:complexType name="elem_int_t">
<xs:attribute ref="attr_int_0_100"/>
</xs:complexType>
- the element declaration:
<xs:element name="elem_int" type="elem_int_t"/>
2) C++
XMLGrammarPool *pool = new XMLGrammarPoolImpl();
XercesDOMParser *parser = new XercesDOMParser(0,
XMLPlatformUtils::fgMemoryManager, pool);
//load the schema grammar
parser->loadGrammar("test.xsd", Grammar::SchemaGrammarType, true);
//get the schema's target namespace
XSNamespaceItem *namespaceItem =
model->getNamespaceItem(grammar->getTargetNamespace());
//NB. the function LocToUniString converts const char* to const XMLCh*
//STEP 1: get the global complex type definition from the namespace
XSTypeDefinition *t1 =
namespaceItem->getTypeDefinition(LocToUniString("elem_int_t"));
XSComplexTypeDefinition *d1 =
static_cast<XSComplexTypeDefinition*>(t1);
std::cout
<< "\nName: " << d1->getName()
<< "\nAttributeUses: " << d1->getAttributeUses();
OUTPUT:
Name: elem_int_t CORRECT
AttributeUses: 0 WRONG
//STEP 2: get the global complex type definition from the element
declaration
XSElementDeclaration *e =
namespaceItem->getElementDeclaration(LocToUniString("elem_int");
XSTypeDefinition *t2 = e->getTypeDefinition();
XSComplexTypeDefinition *d2 =
static_cast<XSComplexTypeDefinition*>(t2);
std::cout
<< "\nName: " << d2->getName()
<< "\nAttributeUses: " << d2->getAttributeUses();
OUTPUT:
Name: anyType WRONG
AttributeUses: 0 WRONG
and also: d1 != d2 (as pointers)
Please, note that doing the same for global attributes I get correct
output; i.e. XSSimpleTypeDefinition works fine.
Any idea?
Thanks a lot
Raffaele
--
Using Opera's revolutionary email client: http://www.opera.com/mail/