declxml icon indicating copy to clipboard operation
declxml copied to clipboard

Access a node's parent attribute

Open marnunez opened this issue 7 years ago • 2 comments

Hi! Is this funcionality implemented?

xml.integer('..', attribute='nFrames', alias='_nFrames')]

I need for each child to have a copy of its parent "nFrames" attribute. Is this achievable with XPath?

marnunez avatar Mar 26 '18 18:03 marnunez

I think that should be possible, but it would be good to add some tests to verify it is possible. One thing we would need to consider is what to do when serializing the value since we will have multiple items referring to the same attribute. Do we let the first value we encounter win and make that the value of the attribute when serializing? What do we do if the items that should serialize to the same attribute have different values?

gatkin avatar Mar 28 '18 19:03 gatkin

I think it should be the last item serialized that defines its parent's attribute, just like with normal variables. I'm not sure how this is implemented in other parsers.

marnunez avatar Mar 28 '18 20:03 marnunez