Hi Everyone,
When processing another schema, I found a case where invalid method names
are being generated. The error occurs when an element or type name is
hyphenated. In my test case, there is an element called
"configuration-property", which is used in a complex type called
"system-configurationListType". After the interface is generated,
the system_configurationListType object has a method
self.validate_configuration-property(self.configuration_property)
rather than
self.validate_configuration_property(self.configuration_property)
The handler class for configuration-property makes reference to
obj = configuration-property.factory()
when it should refer to
obj = configuration_property.factory()
I've attached a copy of the XML Schema file that demonstrates the
problem and a patch that appears to fix it.
Regards,
Arne
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
- Alarm System Schema
-
- Author:
- Francesco Calderini (CERN)
- Klemen Zagar (Cosylab)
-
- History:
- 2005-02-10 CERN Code given to ESO
- 2005-06-13 KZ Added target namespace (for CDB validation)
-->
<xs:schema targetNamespace="urn:schemas-cosylab-com:AcsAlarmSystem:1.0"
xmlns="urn:schemas-cosylab-com:AcsAlarmSystem:1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="configuration-property">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:complexType name="system-configurationListType">
<xs:sequence>
<xs:element ref="configuration-property" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
diff -Naur generateDS-1.14e/generateDS.py generateDS-1.14f/generateDS.py
--- generateDS-1.14e/generateDS.py 2008-10-07 15:21:31.000000000 +0000
+++ generateDS-1.14f/generateDS.py 2008-10-07 15:58:30.000000000 +0000
@@ -2167,7 +2176,7 @@
typeName = ElementDict[childType].getType()
if typeName:
s1 = " self.validate_%s(self.%s) # validate type %s\n" %
(
- typeName, mappedName, typeName, )
+ mappedName, mappedName, typeName, )
outfile.write(s1)
@@ -2868,7 +2877,7 @@
def generateSAXStartElement(outfile, root, elementList):
wrt = outfile.write
name = root.getChildren()[0].getName()
- s1 = SAX_STARTELEMENT_1 % (name, name, name)
+ s1 = SAX_STARTELEMENT_1 % (name, cleanupName(mapName(name)), name)
wrt(s1)
for element, parent in elementList:
generateSAXStartElement_1(wrt, element)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users