[xsd-users] string literal definitions for element names
Leonid Gershanovich
gleonid at yahoo.com
Tue Jan 12 12:27:19 EST 2010
Hi Boris,
is there a way to instruct generator to produce set of string literal definitions for element/attribute names?
let say that I have a very simple schema(sample.xsd):
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace ="http://schemas.mydomain.com/sample"
xmlns="http://schemas.mydomain.com/sample"
elementFormDefault="qualified"
>
<xs:element name="sample_el">
<xs:complexType/>
</xs:element>
</xs:schema>
------------------------
Then I generate SAX wrappers with expat and driver code with following command:
./CodeSynthesis/3.2.0/bin/xsd cxx-parser \
--xml-parser expat \
--skel-type-suffix _sax_interface \
--skel-file-suffix -sax_interface \
--impl-type-suffix "-sax_impl" \
--impl-file-suffix "-sax_impl" --generate-print-impl --impl-file-suffix "-sax_impl" --generate-test-driver \
--hxx-suffix .h \
--ixx-suffix .ipp \
--cxx-suffix .cpp \
--proprietary-license \
sample.xsd
In sample-driver.cpp I am getting code like this:
--------------------------
::xml_schema1::document doc_p (
sample_el_p,
"http://schemas.247realmedia.com/sample",
"sample_el");
--------------------------
Ideally I do not want to have neither element name nor xml namspace hardcoded in my program, but I could not find in generated code any way to do this otherwise.
Idea is that if I decide to change schema and rename element/attribute/targetNamespace I I would want my code to stop compiling, but with hardcoded literals I would have to go thru my code and make sure that names in schema are in sync with whatever is hardcoded.
Thanks
Leonid Gershanovich
More information about the xsd-users
mailing list