sabre-io / xml

sabre/xml is an XML library that you may not hate.
http://sabre.io/xml/
BSD 3-Clause "New" or "Revised" License
515 stars 77 forks source link

Reparse element with same reader #280

Open Zekfad opened 4 months ago

Zekfad commented 4 months ago

I'm in process of writing annotation (php 8.3) based (de)serialize methods and thinking about how to implement polymorphic node (select in xsd).

While it's possible to make an educated guess, meaning analyze candidate structures and try to see which one xml is actually follows, I think that solution is overly complicated to get it right.

I think of a try-catch parsing every candidate until first match. But to do so I need a way to reparse element with current reader options.

I'm thinking about cloning reader options to a new one and use fragment to get a stable copy of element descendants. Is there any better or convenient ways to achieve it?