[xsd-users] Problems with generated schema
ope
ope-devel at gmx.de
Sat Jul 21 13:33:42 EDT 2007
Hi,
I build a tree parser for the metalink schema at
http://www.metalinker.org/schema/3.0/metalink.xsd by:
xsd cxx-tree \
--namespace-map http://www.metalinker.org/=metalink \
--generate-ostream \
--hxx-suffix .hpp \
--cxx-suffix .cpp metalink.xsd
and use it in that manner:
---8<--- header ---8<---
class metalink_parser {
private:
typedef
std::vector<std::string> metalink_files_t;
....
private:
metalink_files_t m_metalink_files;
std::auto_ptr<metalink::metalinkType> m_metalink;
};
---8<--- header ---8<---
---8<--- source ---8<---
// a simple test with the first entry
const std::string metalink_file = m_metalink_files.front();
try {
// take ownership
m_metalink = metalink::metalink(metalink_file);
metalink::filesType::file::const_iterator
first(m_metalink->files().file().begin());
metalink::filesType::file::const_iterator
last(m_metalink->files().file().begin());
for (; first != last; ++first) {
cout << *first;
}
}
catch (const xml_schema::exception& e) {
cerr << e << endl;
}
---8<--- source ---8<---
and get a lot of errors:
metalink.xsd:2:216 error: Unknown element 'xs:schema'
metalink.xsd:2:216 error: Attribute 'version' is not declared for
element 'xs:schema'
metalink.xsd:2:216 error: Attribute 'xmlns' is not declared for element
'xs:schema'
metalink.xsd:2:216 error: Attribute '{http://www.w3.org/2000/xmlns/}xs'
is not declared for element 'xs:schema'
metalink.xsd:2:216 error: Attribute 'targetNamespace' is not declared
for element 'xs:schema'
metalink.xsd:2:216 error: Attribute 'elementFormDefault' is not declared
for element 'xs:schema'
metalink.xsd:2:216 error: Attribute 'attributeFormDefault' is not
declared for element 'xs:schema'
metalink.xsd:3:54 error: Unknown element 'xs:element'
metalink.xsd:3:54 error: Attribute 'name' is not declared for element
'xs:element'
metalink.xsd:3:54 error: Attribute 'type' is not declared for element
'xs:element'
metalink.xsd:4:38 error: Unknown element 'xs:complexType'
metalink.xsd:4:38 error: Attribute 'name' is not declared for element
'xs:complexType'
metalink.xsd:5:22 error: Unknown element 'xs:sequence'
metalink.xsd:6:76 error: Unknown element 'xs:element'
metalink.xsd:6:76 error: Attribute 'name' is not declared for element
'xs:element'
metalink.xsd:6:76 error: Attribute 'type' is not declared for element
'xs:element'
metalink.xsd:6:76 error: Attribute 'maxOccurs' is not declared for
element 'xs:element'
metalink.xsd:9:41 error: Unknown element 'xs:complexType'
metalink.xsd:9:41 error: Attribute 'name' is not declared for element
'xs:complexType'
...
What's gone wrong here?
Anyway, how can I rename the anonymous types with useful names other
than counted version1 (or hash1 by use of xsd 3.0.0b2)?
Thanks
Olaf
More information about the xsd-users
mailing list