Well, yes and no.

When i change the call to generateDS to include

--root-element=ResourceType

i get an output for the attached test.xml (test.xml.out) when i run it
through test.py, but it is different from the input file, which is not
really what i would expect. And it's only different for the root node,
although PersonInfo and IdentificationInfo are specified in much the
same way as Resource, i.e., with a type name different from the tag
name.

So it seems to me that this is more a problem of Resource being the
root tag that is not embedded into any other tag. I'd be happy to
look into the code to find the problem myself, now that i see that it
works in principle and i've not completely misunderstood; if you could
give me a hint where to look first, i'd be very grateful.

Thanks for your time,

        Bernd

On 13.11.2011 22:58, Dave Kuhlman wrote:
From: Bernd Kiefer<kie...@dfki.de>
Sent: Wednesday, November 9, 2011 3:15 AM




i've problems converting the given schema. The root element (Resource)
does not show up anywhere in the generated code, and thus,
parsing only gives my an empty myString element. I used the following
command to generate test.py

python generateDS.py -f -a "" \
       --namespacedef='xmlns:ms="http://www.dfki.de/testschema"; xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://www.dfki.de/testschema"; elementFormDefault="qualified" 
attributeFormDefault="unqualified"' \
       -o test.py \
       testschema.xsd

omitting `-a ""' or using `-a "ms:"' also did not help.


Bernd -

OK. I'll admit I had to think about this for awhile before I came up
with an answer.  And I *think* it's the answer that we want.

That<xs:element>  declaration at the top level is telling us that an
element whose tag is "Resource" can occur at top level, but that it's
class is ResourceType.  So we do not need to generate a Resource
class, only a ResourceType class.   Take a look at the parse()
function in the generated code.  You will notice that it is trying
to parse an element whose tag is "Resource" and turning it into a
instance of the Python class ResourceType, which is what we want, I
believe.

So, it's generating what you want, I think, or at least it's
generating what the testschema.xsd says you want.  It's generating
Python code and Python classes (data bindings) that will parse an
XML instance document containing a "Resource" element at top level
and will turn that top level element into an instance of class
ResourceType.

In general, we generate Python classes for xs:complexType
declarations, but not for xs:element declarations.

Please let me know if you disagree or have more questions.

- Dave




--
----------------------------------------------------------------------
Bernd Kiefer     DFKI GmbH,  Stuhlsatzenhausweg,  D-66123 Saarbruecken
kie...@dfki.de   +49-681/85775-5301 (phone)   +49-681/85775-5338 (fax)
----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Trippstadter Strasse 122, D-67663 Kaiserslautern, Germany
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster (Vor-
                    sitzender), Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
<?xml version="1.0" encoding="UTF-8"?>
<Resource xsi:schemaLocation="http://www.dfki.de/testschema testschema.xsd" xmlns:ms="http://www.dfki.de/testschema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <ms:IdentificationInfo>
    <ms:resourceName>myResource</ms:resourceName>
  </ms:IdentificationInfo>
  <ms:PersonInfo>
    <ms:surname>Heinz</ms:surname>
  </ms:PersonInfo>
  <ms:PersonInfo>
    <ms:surname>John</ms:surname>
    <ms:givenName>Doe</ms:givenName>
  </ms:PersonInfo>
</Resource>
<?xml version="1.0" ?>
<ms:ResourceType xmlns:ms="http://www.dfki.de/testschema"; xmlns:xs="http://www.w3.org/2001/XMLSchema"; targetNamespace="http://www.dfki.de/testschema"; elementFormDefault="qualified" attributeFormDefault="unqualified">
    <ms:IdentificationInfo>
        <ms:resourceName>myResource</ms:resourceName>
    </ms:IdentificationInfo>
    <ms:PersonInfo>
        <ms:surname>Heinz</ms:surname>
    </ms:PersonInfo>
    <ms:PersonInfo>
        <ms:surname>John</ms:surname>
        <ms:givenName>Doe</ms:givenName>
    </ms:PersonInfo>
</ms:ResourceType>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to