extbase object to xml mapping
TRANSCRIPT
![Page 1: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/1.jpg)
ExtbaseObject to XML Mapping
Thomas Maroschik
![Page 2: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/2.jpg)
Agenda
• XML basics
• Current state of EXT:palm
• Fail of EXT:palm
• Vision and the future
• Discussion
![Page 3: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/3.jpg)
XML Basics
![Page 4: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/4.jpg)
Key Technologies
• XML
• Schema
• DTD
• XSD
• RelaxNG
• XPath / XQuery
• XSLT
![Page 5: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/5.jpg)
XML Document
![Page 6: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/6.jpg)
XML Namespace
![Page 7: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/7.jpg)
XML Namespaces
![Page 8: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/8.jpg)
XML Schema (DTD)Deprecated, W3C Recommendation
![Page 9: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/9.jpg)
XML Schema (XSD)Popular, W3C Recommendation
![Page 10: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/10.jpg)
XML Schema (RelaxNG)Popular, Oasis/ISO Standard
![Page 11: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/11.jpg)
XPath
/bookshelf/book/title/bookshelf/book[1]/title
/bookshelf/book/author/text()/bookshelf/book[price<37]/title
![Page 12: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/12.jpg)
XSLT
![Page 13: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/13.jpg)
Current State of EXT:palm
![Page 14: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/14.jpg)
Features• Generate XML schema (XSD) from annotated
Domain Models
• Serialize instances of Domain Models to XML document
• Unserialize XML document to instances of Domain Models
• merging of XML data with existing data from repositories by rules
• Backend module
• Scheduler task
• No XML Namespaces yet
![Page 15: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/15.jpg)
Example Domain Model
![Page 16: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/16.jpg)
Example Palm Usage
![Page 17: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/17.jpg)
Example Palm Merger Usage
![Page 18: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/18.jpg)
Live Demo
![Page 19: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/19.jpg)
Fail of EXT:palm
![Page 20: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/20.jpg)
Inner Concept
• uses annotations for binding
• uses reflection for mapping
• serializing and unserializing is configurable by typoscript
• uses DOM for XML access
![Page 21: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/21.jpg)
Serializer Concept
• iterates recursively over object
• builds DOMDocument directly
=> 2 in memory representations of data
![Page 22: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/22.jpg)
Unserializer Concept
• iterates recursively over DOMDocument
• maps the data to an array
• array is mapped to object by property mapper
=> 3 in memory representations of data
![Page 23: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/23.jpg)
Merger Concept
• can import/merge external data by unserializing xml to object
• fetches domain object from repository
• compares objects and applies changes by rules
=> 4 in memory representations of data
![Page 24: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/24.jpg)
But why does this fail?
![Page 25: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/25.jpg)
Reasons for Fail
• everything is defined global
• domain object cannot be serialized to different xml outputs
• configuration via TS in Extbase is flawed
• massive memory consumption
• reflection is quite slow
![Page 26: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/26.jpg)
Conclusion
• currently just usable for limited usecases
![Page 27: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/27.jpg)
Hacks to get it work
• import/merge all of a 2,2MB XML file takes of up to 2,5GB of memory
• 2 scheduler tasks
• one that populates a jobqueue
• one that does just a single import/merge at a time (import of 60 aggregate roots takes 60 Minutes)
![Page 28: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/28.jpg)
Vision and the future
![Page 29: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/29.jpg)
ConceptXML Schema
Classes
BindingXML Data
serialize
unserialize
Object
serialize
unserialize
generate
generate
use
use
![Page 30: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/30.jpg)
Implementation Concept
• binding will be done by a binding document instead of annotations
=> xml and objects may have very different structure=> custom un-/serializers for data types=> no global configuration anymore
• compile binding to php=> no reflection at runtime anymore
• use xml reader/writer instead DOM=> save memory and gain speed
![Page 31: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/31.jpg)
How could the binding look like?
Example from jibx.sourceforge.net
![Page 32: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/32.jpg)
What do you think?
![Page 33: Extbase object to xml mapping](https://reader034.vdocuments.mx/reader034/viewer/2022052509/55a1d1ce1a28abaf468b480e/html5/thumbnails/33.jpg)
Thanks!
Contact me via:
@tom_noise
Contribute via:
forge.typo3.org/projects/extension-palm/