-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send xml data to constructor #12
Comments
That is a great suggestion. You are right, currently there is no way in declxml to have values sent to a class constructor; declxml calls Hmm...I think this would be possible. When parsing XML data for objects, declxml reads all the data into a dict first and then creates a new instance of the object before setting all attribute values with What do you think of that solution? |
That sounds like a great idea! Another would be to just take a "data" argument, and send in all the raw data to the constructor. Either way my code would be much nicer, when not having to create an object with the raw values first, and then send them to the constructor for refinement. |
Ohh this would be really nice, I've used construct's Adapters like this. In my case, I'd rather not send to the constructor just a single attribute. I'm facing XML tags like the following: <track coords="X Y Z" data="S 255 33845 12623 4773 33791..." description="" label="cat7" nItems="-1" nPoints="584" nSegs="1" scaleFactor="10000.0"/> where I need the coord attribute for making sense out of the data attribute, which is in the form of data = "S start_time X1 Y1 Z1 X2 Y2 Z2... S start_time_2 X1 Y1 Z1" but if data = "S start_time V1 V2 V3 V4 V5 V6... S start_time_2 V1 V2 V3" Embedding this into the parsing logic would free me for the trouble of case by case serialising and deserialising and permit me to work with the data as lists or numpy arrays |
@marnunez would the |
Support for processing hooks to allow this capability is now available in the latest release from PyPi |
Hi! I really like declxml, and it almost does exactly what I was looking for. I understand if this is not something you want to support.
I would like to construct a custom class from an XML file, but do the transformations of the data in the constructor. As I understand the setup right now, attributes are "magically" set from declxml, instead of being sent to the constructor where I could transform them before saving them.
The text was updated successfully, but these errors were encountered: