XML element vs attribute in Ladon custom types

Asked by Alex Railean

Hi,

I have some questions about XML schemas that contain elements with attributes, such as this example: http://pastebin.com/3hgStRi9

This is my attempt to map the above to Ladon types: http://pastebin.com/Xwq30zqk I relied on the dictionary notation to indicate which entries are mandatory and which ones are optional.

1. how to tell Ladon which items are elements and which ones are attributes?
2. related to the above, optional attributes are marked with 'use="optional"', while optional elements are marked as 'minOccurs="0"'. How can this be expressed in Ladon terminology? (example of such a schema http://pastebin.com/Krs83669)
3. some standard types such as "xs:NCName" have no mapping in Ladon, so I chose to declare it as a string. The plan is to create a filter function that will be applied to the input data, it will verify that the string corresponds to NCName requirements (it must not contain ':'). Is this the best approach?

Having reviewed the available documentation, I am still unable to clarify the "attribute vs element" problem. Ladon's doc on types http://packages.python.org/ladon/ladontype.html mentions 'attributes', but I interpret that as "attribute - member of a class", rather than "an attribute of an XML element". I hope you can provide some hints on this matter.

Question information

Language:
English Edit question
Status:
Answered
For:
ladon Edit question
Assignee:
jsgaarde Edit question
Last query:
Last reply:
Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#1

Hi Alex,

dictionary parameters is a very new feature and there might still be som issues. I'll get back to you on this one, I am VERY busy this week, so it might not be until sunday ... Sorry.

Best Regards
Jakob Simon-Gaarde

Revision history for this message
Alex Railean (gr8dude) said :
#2

Thanks, I am standing by :-)

Revision history for this message
Alex Railean (gr8dude) said :
#3

Having read more from the WSDL that I need to implement and having examined parts of Ladon's code, I concluded that there are other matters I don't know how to deal with:
- how to limit the length of a string?
- how to define the possible values of an enumeration?
- how to indicate that an element is of a type from a specific namespace?

At this point, I think I'll have to contribute by submitting some changes to Ladon itself. I'd love to do that, but it would be great if we could talk things over first.

The function analyze_class in typemanager.py is what I think I will have to modify to teach Ladon how to take into account other variations such as (minOccurs, maxOccurs, enumerations, maximum and minimum string lengths, etc).

In the context of SOAP, soap.py is what generates the WSDL, so changes must be applied there too.

There must be some implications I am not aware of yet, I would greatly appreciate it if you could offer some guidance in this matter.

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#4

Hi Alex.

I will definately look at your problem tomorrow evening.

Best Regards
Jakob Simon-Gaarde

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#5

Hi Alex.

> - how to limit the length of a string?
> - how to define the possible values of an enumeration?
> - how to indicate that an element is of a type from a specific namespace?

Ladon doesn't do WSDL to make such limitations. But you can easily make these validations on the serverside using Filter functions: http://packages.python.org/ladon/ladontype.html#reuse-code-for-dictionary-type-definition

Making a contribution is always welcome.

The reason that maximum/minimum and maxOccurs/minOccures have never been implemented is because Ladon didn't have dictionary type definitions. It has now, and it is possible to make such limitations.
So to make these enhancements it is needed to extend the supported parameters of the dictionary type definition. This is done, as you have already found, in the TypeManager class. This should be enough to create service descriptions with builtin limitations.
To actually handle the limitations (ie creating ClientExceptions when limitations are exceeded) it is nessecary to implement checks in LadonType.
It would probably be ok to start out by implementing the first part (description files) and wait with the validation part.

Go ahead and make a patch for typemanager.py and soap.py - we can discus the changes you made afterwards.

Best Regards
Jakob Simon-Gaarde

Can you help with this problem?

Provide an answer of your own, or ask Alex Railean for more information if necessary.

To post a message you must log in.