Vous pourrez affûter vos compétences, découvrir de nouvelles technologies, ou vous inspirer de nouvelles idées et techniques à exploiter dans le cadre de vos projets de développement 4D.
2. 4D Summit 2014 • Paris • Celebrating 30 years
Bruno LEGAY
Responsable Bureau d’Etudes
A&C Consulting
www.ac-consulting.fr
3. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
4. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
• Markup langage
5. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
• Markup langage
• Serialization
6. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
• Markup langage
• Serialization
• Data structure
7. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
• Markup langage
• Serialization
• Data structure
• Data exchange
8. 4D Summit 2014 • Paris • Celebrating 30 years
What is xml ?
• Markup langage
• Serialization
• Data structure
• Data exchange
• Data storage
9. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
10. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
11. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
• Office documents
12. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
• Office documents
• User interface (XUL/XAML)
13. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
• Office documents
• User interface (XUL/XAML)
• Preference files (4D, OS X, etc...)
14. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
• Office documents
• User interface (XUL/XAML)
• Preference files (4D, OS X, etc...)
• Svg
15. 4D Summit 2014 • Paris • Celebrating 30 years
Where is xml ?
• Web (xml-rpc, web-services/SOAP,Ajax, Rss, Atom,
Rest, xhtml)
• Office documents
• User interface (XUL/XAML)
• Preference files (4D, OS X, etc...)
• Svg
• etc...
16. 4D Summit 2014 • Paris • Celebrating 30 years
History of XML
Where does it come from ?
18. 4D Summit 2014 • Paris • Celebrating 30 years
GML
1969 : Generalized Markup Language (IBM)!
Documentation
19. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
20. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
1991 : Hypertext Markup Language (CERN/W3C)!
Hypertext documents
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
HTML
21. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
XML
1991 : Hypertext Markup Language (CERN/W3C)!
Hypertext documents
1998 : eXtensible Markup Language (W3C)!
Anything
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
HTML
22. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
XML
XHTML
2000 : XHTML (W3C)!
1991 : Hypertext Markup Language (CERN/W3C)!
Hypertext documents
1998 : eXtensible Markup Language (W3C)!
Anything
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
HTML
23. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
XML
XHTML
HTML5
2008 : HTML5 (WHATWG / W3C)
2000 : XHTML (W3C)!
1991 : Hypertext Markup Language (CERN/W3C)!
Hypertext documents
1998 : eXtensible Markup Language (W3C)!
Anything
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
HTML
24. 4D Summit 2014 • Paris • Celebrating 30 years
GML
SGML
XML
XHTML
HTML5
2008 : HTML5 (WHATWG / W3C)
2000 : XHTML (W3C)!
1991 : Hypertext Markup Language (CERN/W3C)!
Hypertext documents
1998 : eXtensible Markup Language (W3C)!
Anything
1986 : Standard Generalized Markup Language (ISO)!
Documentation
1969 : Generalized Markup Language (IBM)!
Documentation
SVG
MathML
HTML
25. 4D Summit 2014 • Paris • Celebrating 30 years
XML / HTML
XML HTML
strict loose
26. 4D Summit 2014 • Paris • Celebrating 30 years
XML / HTML
XML HTML
strict loose
case-sensitive case-insensitive
27. 4D Summit 2014 • Paris • Celebrating 30 years
XML / HTML
XML HTML
strict loose
case-sensitive case-insensitive
<emptyTag/> <emptyTag>
28. 4D Summit 2014 • Paris • Celebrating 30 years
XML / HTML
XML HTML
strict loose
case-sensitive case-insensitive
<emptyTag/> <emptyTag>
unlimited tags predefined tags
30. 4D Summit 2014 • Paris • Celebrating 30 years
Before xml
31. 4D Summit 2014 • Paris • Celebrating 30 years
Before xml
• Flat text files
32. 4D Summit 2014 • Paris • Celebrating 30 years
Before xml
• Flat text files
• csv
33. 4D Summit 2014 • Paris • Celebrating 30 years
Before xml
• Flat text files
• csv
• Binary files
34. 4D Summit 2014 • Paris • Celebrating 30 years
Before xml
• Flat text files
• csv
• Binary files
• Propriatery file formats
35. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
36. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
37. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
• Flexible data structure
38. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
• Flexible data structure
• Text based
39. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
• Flexible data structure
• Text based
• Self documented
40. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
• Flexible data structure
• Text based
• Self documented
• Easy to read
41. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml
• Meta markup language
• Flexible data structure
• Text based
• Self documented
• Easy to read
• Strict
42. 4D Summit 2014 • Paris • Celebrating 30 years
Advantages of xml (cont.)
43. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
Advantages of xml (cont.)
44. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
Advantages of xml (cont.)
45. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
• Introspection
Advantages of xml (cont.)
46. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
• Introspection
• Namespaces
Advantages of xml (cont.)
47. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
• Introspection
• Namespaces
• Rich toolset
Advantages of xml (cont.)
48. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
• Introspection
• Namespaces
• Rich toolset
• Compression friendly
Advantages of xml (cont.)
49. 4D Summit 2014 • Paris • Celebrating 30 years
• Validity checking
• Multiple encoding support (us-ascii, macroman,
windows1252, iso-8859-1, utf-8, etc...)
• Introspection
• Namespaces
• Rich toolset
• Compression friendly
• Comments
Advantages of xml (cont.)
50. 4D Summit 2014 • Paris • Celebrating 30 years
Examples
start tag end tag
attribute
51. 4D Summit 2014 • Paris • Celebrating 30 years
Empty elements
52. 4D Summit 2014 • Paris • Celebrating 30 years
Element vs Attribute
Element Attribute
Unique no yes
53. 4D Summit 2014 • Paris • Celebrating 30 years
Element vs Attribute
Element Attribute
Unique no yes
Ordered yes no
54. 4D Summit 2014 • Paris • Celebrating 30 years
Element vs Attribute
Element Attribute
Unique no yes
Ordered yes no
Can have children yes no
55. 4D Summit 2014 • Paris • Celebrating 30 years
Element vs Attribute
Element Attribute
Unique no yes
Ordered yes no
Can have children yes no
Can have attributes yes no
56. 4D Summit 2014 • Paris • Celebrating 30 years
Element vs Attribute
Element Attribute
Unique no yes
Ordered yes no
Can have children yes no
Can have attributes yes no
Normalized no yes
59. 4D Summit 2014 • Paris • Celebrating 30 years
Common mistake
redundant information
60. 4D Summit 2014 • Paris • Celebrating 30 years
XML document
61. 4D Summit 2014 • Paris • Celebrating 30 years
XML document
prolog
62. 4D Summit 2014 • Paris • Celebrating 30 years
XML document
prolog
xml declaration
63. 4D Summit 2014 • Paris • Celebrating 30 years
XML document
prolog
xml declaration
Document type declaration
64. 4D Summit 2014 • Paris • Celebrating 30 years
XML document
prolog
xml declaration
root element
Document type declaration
65. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
66. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
67. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
68. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
• version is mandatory (usually “1.0”)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
69. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
• version is mandatory (usually “1.0”)
• encoding is optional (default “UTF-8”)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
70. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
• version is mandatory (usually “1.0”)
• encoding is optional (default “UTF-8”)
• standalone is optional (default “no”)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
71. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
• version is mandatory (usually “1.0”)
• encoding is optional (default “UTF-8”)
• standalone is optional (default “no”)
• DTD (Document Type Definition) is optional
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
72. 4D Summit 2014 • Paris • Celebrating 30 years
XML prolog
• Prolog is optional
• XML declaration is optional
• version is mandatory (usually “1.0”)
• encoding is optional (default “UTF-8”)
• standalone is optional (default “no”)
• DTD (Document Type Definition) is optional
• Unicode BOM (Byte Order Mark) is allowed
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
…
73. 4D Summit 2014 • Paris • Celebrating 30 years
Comments
comments
74. 4D Summit 2014 • Paris • Celebrating 30 years
Predefined entities
Name Character Unicode xml html
quot " U+0022 (34) xml 1.0 html 2.0
amp & U+0026 (38) xml 1.0 html 2.0
apos ' U+0027 (39) xml 1.0 xhtml 1.0
lt < U+003C (60) xml 1.0 html 2.0
gt > U+003E (62) xml 1.0 html 2.0
75. 4D Summit 2014 • Paris • Celebrating 30 years
Character entity decimal :
Character entities
76. 4D Summit 2014 • Paris • Celebrating 30 years
Character entity decimal :
Character entity hexadecimal :
Character entities
77. 4D Summit 2014 • Paris • Celebrating 30 years
Character entity decimal :
Character entity hexadecimal :
Character entities
78. 4D Summit 2014 • Paris • Celebrating 30 years
Custom entities
Declaration :
79. 4D Summit 2014 • Paris • Celebrating 30 years
Custom entities
Declaration :
Usage :
80. 4D Summit 2014 • Paris • Celebrating 30 years
Custom entities
Declaration :
Usage :
81. 4D Summit 2014 • Paris • Celebrating 30 years
Namespace
Default namespace
82. 4D Summit 2014 • Paris • Celebrating 30 years
Namespace
Default namespace
Custom namespace
83. 4D Summit 2014 • Paris • Celebrating 30 years
Mixed content
84. 4D Summit 2014 • Paris • Celebrating 30 years
Mixed content
85. 4D Summit 2014 • Paris • Celebrating 30 years
PCDATA (parsed) vs CDATA (unparsed)
86. 4D Summit 2014 • Paris • Celebrating 30 years
PCDATA (parsed) vs CDATA (unparsed)
87. 4D Summit 2014 • Paris • Celebrating 30 years
PCDATA (parsed) vs CDATA (unparsed)
88. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
89. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
• “Well formed” : xml syntax is ok
90. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
• “Well formed” : xml syntax is ok
• Well formed is mandatory
91. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
• “Well formed” : xml syntax is ok
• Well formed is mandatory
• “Valid” : schema follows DTD or Schema (.xsd)
92. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
• “Well formed” : xml syntax is ok
• Well formed is mandatory
• “Valid” : schema follows DTD or Schema (.xsd)
• DTD or Schema describe the structure of an xml
document
93. 4D Summit 2014 • Paris • Celebrating 30 years
Validation
• “Well formed” : xml syntax is ok
• Well formed is mandatory
• “Valid” : schema follows DTD or Schema (.xsd)
• DTD or Schema describe the structure of an xml
document
• Validation is optional (but it will make your code
simpler and more resilient)
94. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
95. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
96. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
Embedded possible no
97. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
Embedded possible no
Flexibility good best
98. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
Embedded possible no
Flexibility good best
Type checking limited powerful
99. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
Embedded possible no
Flexibility good best
Type checking limited powerful
Custom entity yes no
100. 4D Summit 2014 • Paris • Celebrating 30 years
DTD vs Schema
DTD Schema
Extension .dtd .xsd
Syntax specific xml
Embedded possible no
Flexibility good best
Type checking limited powerful
Custom entity yes no
Part of XML specs yes no
101. 4D Summit 2014 • Paris • Celebrating 30 years
DTD example
102. 4D Summit 2014 • Paris • Celebrating 30 years
External DTD example
103. 4D Summit 2014 • Paris • Celebrating 30 years
Schema example
105. 4D Summit 2014 • Paris • Celebrating 30 years
XPath
• XPath allows selection of nodes of an xml document with
expressions
106. 4D Summit 2014 • Paris • Celebrating 30 years
XPath
• XPath allows selection of nodes of an xml document with
expressions
• Indexed selection
/children/child[2]
107. 4D Summit 2014 • Paris • Celebrating 30 years
XPath
• XPath allows selection of nodes of an xml document with
expressions
• Indexed selection
/children/child[2]
• More powerful selection (functions, boolean operators, etc...)
/children/child[@name="Orville"]
109. 4D Summit 2014 • Paris • Celebrating 30 years
XSLT
• Extensible Stylesheet Language Transformations
110. 4D Summit 2014 • Paris • Celebrating 30 years
XSLT
• Extensible Stylesheet Language Transformations
• XSLT purpose is to process an xml document and generate an
output (xml, html, text, etc...)
111. 4D Summit 2014 • Paris • Celebrating 30 years
XSLT
• Extensible Stylesheet Language Transformations
• XSLT purpose is to process an xml document and generate an
output (xml, html, text, etc...)
• Relies on XPath
113. 4D Summit 2014 • Paris • Celebrating 30 years
Storage
• Text or blob ?
114. 4D Summit 2014 • Paris • Celebrating 30 years
Storage
• Text or blob ?
• Text encoding can be ambiguous if non Unicode is
used
115. 4D Summit 2014 • Paris • Celebrating 30 years
Storage
• Text or blob ?
• Text encoding can be ambiguous if non Unicode is
used
• Blob can be compressed
116. 4D Summit 2014 • Paris • Celebrating 30 years
Storage
• Text or blob ?
• Text encoding can be ambiguous if non Unicode is
used
• Blob can be compressed
• Check that your xml is well formed
119. 4D Summit 2014 • Paris • Celebrating 30 years
Tools
• Basic text editor (TextEdit, Notepad, vi, etc...)
120. 4D Summit 2014 • Paris • Celebrating 30 years
Tools
• Basic text editor (TextEdit, Notepad, vi, etc...)
• Advanced text editor (TextWrangler, Notepad++, etc...)
121. 4D Summit 2014 • Paris • Celebrating 30 years
Tools
• Basic text editor (TextEdit, Notepad, vi, etc...)
• Advanced text editor (TextWrangler, Notepad++, etc...)
• XML Editor (oXygen, XMLSpy, etc...)
122. 4D Summit 2014 • Paris • Celebrating 30 years
Tools
• Basic text editor (TextEdit, Notepad, vi, etc...)
• Advanced text editor (TextWrangler, Notepad++, etc...)
• XML Editor (oXygen, XMLSpy, etc...)
• xmllint (part of libxml2)
123. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
124. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
125. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
126. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
• SAX, DOM and Schemas : Xerces
127. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
• SAX, DOM and Schemas : Xerces
• XSLT : Xalan
128. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
• SAX, DOM and Schemas : Xerces
• XSLT : Xalan
• “XSLT plugin” (Miyako) : libxml
129. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
• SAX, DOM and Schemas : Xerces
• XSLT : Xalan
• “XSLT plugin” (Miyako) : libxml
• XML Plugin (Pluggers) : Libxml & Libxslt
130. 4D Summit 2014 • Paris • Celebrating 30 years
Dealing with XML in 4D
• Don’t treat xml as a text file, use xml commands
• 4D (SAX, DOM, Schemas, XSLT)
• SAX, DOM and Schemas : Xerces
• XSLT : Xalan
• “XSLT plugin” (Miyako) : libxml
• XML Plugin (Pluggers) : Libxml & Libxslt
• Expat 4D (Mark Mitchenall) : based on Expat
131. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
132. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
133. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
• SAX : Simple API for XML
134. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
• SAX : Simple API for XML
• SAX parser reads a file sequentially
135. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
• SAX : Simple API for XML
• SAX parser reads a file sequentially
• DOM : Document Object Model
136. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
• SAX : Simple API for XML
• SAX parser reads a file sequentially
• DOM : Document Object Model
• W3C standard for xml and html
137. 4D Summit 2014 • Paris • Celebrating 30 years
SAX / DOM
• 4D has two parser APIs
• SAX : Simple API for XML
• SAX parser reads a file sequentially
• DOM : Document Object Model
• W3C standard for xml and html
• DOM parser loads the xml “in memory”
138. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
139. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
140. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
141. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
142. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
Xpath no yes
143. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
Xpath no yes
Type Read|Write Read+Write
144. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
Xpath no yes
Type Read|Write Read+Write
Modification no yes
145. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
Xpath no yes
Type Read|Write Read+Write
Modification no yes
Target File
File, text,
blob, http
146. 4D Summit 2014 • Paris • Celebrating 30 years
SAX vs DOM
SAX DOM
Memory footprint small proportional
Document Size big small
Scalablity good limited
Validation no yes
Xpath no yes
Type Read|Write Read+Write
Modification no yes
Target File
File, text,
blob, http
* SAX is a read only API. 4D has a “SAX” parser/reader. 4D has also a sequential xml writer named “SAX”.
147. 4D Summit 2014 • Paris • Celebrating 30 years
DOM with large XML...
148. 4D Summit 2014 • Paris • Celebrating 30 years
SAX Examples
149. 4D Summit 2014 • Paris • Celebrating 30 years
Sax parsing
150. 4D Summit 2014 • Paris • Celebrating 30 years
Sax parsing
151. 4D Summit 2014 • Paris • Celebrating 30 years
Sax writing
152. 4D Summit 2014 • Paris • Celebrating 30 years
DOM Examples
165. 4D Summit 2014 • Paris • Celebrating 30 years
Process 4D Tags
166. 4D Summit 2014 • Paris • Celebrating 30 years
Office file formats
167. 4D Summit 2014 • Paris • Celebrating 30 years
Office file formats
OpenDocument Office Open XML
OASIS Microsoft
Open Office MS Office : Word, Excel
odf
WordML
SpreadsheetML
ooxml
2005 2003 2007
.odt, .ods,
etc...
.xml
.docx, .xlsx,
etc...
zip + xml xml zip + xml
170. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
171. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
• xml based
172. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
• xml based
• Light, scales smoothly
173. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
• xml based
• Light, scales smoothly
• Supported in most modern browser
174. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
• xml based
• Light, scales smoothly
• Supported in most modern browser
• Supported in 4D (natively)
175. 4D Summit 2014 • Paris • Celebrating 30 years
SVG
• SVG :“ScalableVector Graphics” image format
• xml based
• Light, scales smoothly
• Supported in most modern browser
• Supported in 4D (natively)
• 4D provides “SVG Component” and “SVG Area”
176. 4D Summit 2014 • Paris • Celebrating 30 years
SVG example
177. 4D Summit 2014 • Paris • Celebrating 30 years
SVG example
178. 4D Summit 2014 • Paris • Celebrating 30 years
SVG in plain 4D
179. 4D Summit 2014 • Paris • Celebrating 30 years
SVG with “4D SVG”
component
180. 4D Summit 2014 • Paris • Celebrating 30 years
C_OBJET and
JSON
181. 4D Summit 2014 • Paris • Celebrating 30 years
JSON format
182. 4D Summit 2014 • Paris • Celebrating 30 years
JSON format
183. 4D Summit 2014 • Paris • Celebrating 30 years
JSON format
184. 4D Summit 2014 • Paris • Celebrating 30 years
JSON format
185. 4D Summit 2014 • Paris • Celebrating 30 years
JSON example
<children><child dob="1867-04-16" name="Wilbur"/><child dob="1871-08-19" name="Orville"/></children>
{"child":[{"name":"Orville","dob":"1871-08-19"},{"name":"Orville","dob":"1871-08-19"}]}
JSON :
XML :
JSON compact :
XML compact :
186. 4D Summit 2014 • Paris • Celebrating 30 years
C_OBJECT to JSON
code
187. 4D Summit 2014 • Paris • Celebrating 30 years
JSON to C_OBJECT
code
188. 4D Summit 2014 • Paris • Celebrating 30 years
Can C_OBJECT work
with XML ?
189. 4D Summit 2014 • Paris • Celebrating 30 years
C_OBJECT to XML
code
190. 4D Summit 2014 • Paris • Celebrating 30 years
C_OBJECT to XML
code (cont.)
191. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
192. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
193. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
194. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
195. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
Mixed mode yes no
196. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
Mixed mode yes no
Namespace yes no
197. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
Mixed mode yes no
Namespace yes no
Conformity dtd, schema no
198. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
Mixed mode yes no
Namespace yes no
Conformity dtd, schema no
Direct Access yes (xpath) no
199. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON
XML JSON
Approach tree list
Arrays no yes
Encoding many utf-8
Comments yes no
Mixed mode yes no
Namespace yes no
Conformity dtd, schema no
Direct Access yes (xpath) no
Transformation yes (xslt) no
200. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON (in 4D)
XML JSON
Debugger friendly no yes
201. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON (in 4D)
XML JSON
Debugger friendly no yes
Native type no yes
202. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON (in 4D)
XML JSON
Debugger friendly no yes
Native type no yes
Memory leak possible no
203. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON (in 4D)
XML JSON
Debugger friendly no yes
Native type no yes
Memory leak possible no
Large documents yes (sax) no
204. 4D Summit 2014 • Paris • Celebrating 30 years
XML vs JSON (in 4D)
XML JSON
Debugger friendly no yes
Native type no yes
Memory leak possible no
Large documents yes (sax) no
Available since 4D v2003 4D v14
205. 4D Summit 2014 • Paris • Celebrating 30 years
Does JSON make XML
obsolete ?
206. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
207. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
208. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
209. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
• JSON features are a subset of XML features
210. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
• JSON features are a subset of XML features
• JSON is relevant in a “small” subset of XML
“market” (web 2.0, web-services)
211. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
• JSON features are a subset of XML features
• JSON is relevant in a “small” subset of XML
“market” (web 2.0, web-services)
• Performance gain should be measured not guessed
212. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
• JSON features are a subset of XML features
• JSON is relevant in a “small” subset of XML
“market” (web 2.0, web-services)
• Performance gain should be measured not guessed
• Web-Services APIs can provide both XML and JSON
213. 4D Summit 2014 • Paris • Celebrating 30 years
Why XML is still
relevant
• XML is an industry standard
• XML has rich tool set
• JSON features are a subset of XML features
• JSON is relevant in a “small” subset of XML
“market” (web 2.0, web-services)
• Performance gain should be measured not guessed
• Web-Services APIs can provide both XML and JSON
• Choice is good
214. 4D Summit 2014 • Paris • Celebrating 30 years
Demonstration
215. 4D Summit 2014 • Paris • Celebrating 30 years
Thank you!
http://www.w3.org/TR/xml/
http://www.w3.org/TR/xml11/
http://www.w3schools.com
http://www.oxygenxml.com/
http://www.saxproject.org
https://github.com/miyako/4d-plugin-xslt
216. 4D Summit 2014 • Paris • Celebrating 30 years
Thank you!
Bruno LEGAY
Responsable Bureau d’Etudes
A&C Consulting
www.ac-consulting.fr