Extbase object to xml mapping

33
Extbase Object to XML Mapping Thomas Maroschik

Transcript of Extbase object to xml mapping

Page 1: Extbase object to xml mapping

ExtbaseObject to XML Mapping

Thomas Maroschik

Page 2: Extbase object to xml mapping

Agenda

• XML basics

• Current state of EXT:palm

• Fail of EXT:palm

• Vision and the future

• Discussion

Page 3: Extbase object to xml mapping

XML Basics

Page 4: Extbase object to xml mapping

Key Technologies

• XML

• Schema

• DTD

• XSD

• RelaxNG

• XPath / XQuery

• XSLT

Page 5: Extbase object to xml mapping

XML Document

Page 6: Extbase object to xml mapping

XML Namespace

Page 7: Extbase object to xml mapping

XML Namespaces

Page 8: Extbase object to xml mapping

XML Schema (DTD)Deprecated, W3C Recommendation

Page 9: Extbase object to xml mapping

XML Schema (XSD)Popular, W3C Recommendation

Page 10: Extbase object to xml mapping

XML Schema (RelaxNG)Popular, Oasis/ISO Standard

Page 11: Extbase object to xml mapping

XPath

/bookshelf/book/title/bookshelf/book[1]/title

/bookshelf/book/author/text()/bookshelf/book[price<37]/title

Page 12: Extbase object to xml mapping

XSLT

Page 13: Extbase object to xml mapping

Current State of EXT:palm

Page 14: Extbase object to xml mapping

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

Example Domain Model

Page 16: Extbase object to xml mapping

Example Palm Usage

Page 17: Extbase object to xml mapping

Example Palm Merger Usage

Page 18: Extbase object to xml mapping

Live Demo

Page 19: Extbase object to xml mapping

Fail of EXT:palm

Page 20: Extbase object to xml mapping

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

Serializer Concept

• iterates recursively over object

• builds DOMDocument directly

=> 2 in memory representations of data

Page 22: Extbase object to xml mapping

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

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

But why does this fail?

Page 25: Extbase object to xml mapping

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

Conclusion

• currently just usable for limited usecases

Page 27: Extbase object to xml mapping

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

Vision and the future

Page 29: Extbase object to xml mapping

ConceptXML Schema

Classes

BindingXML Data

serialize

unserialize

Object

serialize

unserialize

generate

generate

use

use

Page 30: Extbase object to xml mapping

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

How could the binding look like?

Example from jibx.sourceforge.net

Page 32: Extbase object to xml mapping

What do you think?

Page 33: Extbase object to xml mapping

Thanks!

Contact me via:

[email protected]

@tom_noise

Contribute via:

forge.typo3.org/projects/extension-palm/