@@ -237,18 +237,18 @@ The Document
237
237
If you loaded the example odML file, let's have a first look at the Document::
238
238
239
239
>>> print odmlEX
240
- <Doc 42 by D. N. Adams ( 2 sections)>
240
+ Document 42 {author = D. N. Adams, 2 sections}
241
241
242
242
As you can see, the printout gives you a short summary of the Document of the
243
243
loaded example odML file.
244
244
245
245
The print out gives you already the follwing information about the odML file:
246
246
247
- - ``<...> `` indicates that you are looking at an object
248
- - ``Doc `` tells you that you are looking at an odML Document
247
+ - ``Document `` tells you that you are looking at an odML Document
249
248
- ``42 `` is the user defined version of this odML file
250
- - ``by D. N. Adams `` states the author of the odML file
251
- - ``(2 sections) `` tells you that this odML Document has 2 Section directly
249
+ - ``{...} `` provides ``author `` and number of attached sections
250
+ - ``author `` states the author of the odML file, "D. N. Adams" in the example case
251
+ - ``2 sections `` tells you that this odML Document has 2 Section directly
252
252
appended
253
253
254
254
Note that the Document printout tells you nothing about the depth of the
@@ -289,7 +289,7 @@ Let's check out all attributes with the following commands::
289
289
>>> print(odmlEX.date)
290
290
1979-10-12
291
291
>>> print(odmlEX.document)
292
- <Doc 42 by D. N. Adams ( 2 sections)>
292
+ Document 42 {author = D. N. Adams, 2 sections}
293
293
>>> print(odmlEX.parent)
294
294
None
295
295
>>> print(odmlEX.repository)
@@ -307,7 +307,8 @@ Sections were attached to the Document of our example odML file using the
307
307
following command::
308
308
309
309
>>> print(odmlEX.sections)
310
- [Section[4/2] {name = TheCrew, type = crew, id = ...}, Section[1/7] {name = TheStarship, type = starship, id = ...}]
310
+ [Section[4|2] {name = TheCrew, type = crew, id = ...},
311
+ Section[1|7] {name = TheStarship, type = starship, id = ...}]
311
312
312
313
As expected from the Document printout our example contains two Sections. The
313
314
printout and attributes of a Section are explained in the next chapter.
@@ -324,13 +325,13 @@ look at the first Section in the sections list attached to the Document in our
324
325
example odML file::
325
326
326
327
>>> print(odmlEX.sections['TheCrew'])
327
- Section[4/ 2] {name = TheCrew, type = crew, id = ...}
328
+ Section[4| 2] {name = TheCrew, type = crew, id = ...}
328
329
>>> print(odmlEX.sections[0])
329
- Section[4/ 2] {name = TheCrew, type = crew, id = ...}
330
+ Section[4| 2] {name = TheCrew, type = crew, id = ...}
330
331
>>> print(odmlEX['TheCrew'])
331
- Section[4/ 2] {name = TheCrew, type = crew, id = ...}
332
+ Section[4| 2] {name = TheCrew, type = crew, id = ...}
332
333
>>> print(odmlEX[0])
333
- Section[4/ 2] {name = TheCrew, type = crew, id = ...}
334
+ Section[4| 2] {name = TheCrew, type = crew, id = ...}
334
335
335
336
In the following we will call Sections explicitly by their name using the
336
337
short cut notation.
@@ -339,7 +340,7 @@ The printout of a Section is similar to the Document printout and gives you
339
340
already the following information:
340
341
341
342
- ``Section `` tells you that you are looking at an odML Section
342
- - ``[4/ 2] `` states that this Section has four Sections and two Properties directly attached to it
343
+ - ``[4| 2] `` states that this Section has four Sections and two Properties directly attached to it
343
344
- ``{...} `` provides ``name ``, ``type `` and ``id `` of the Section
344
345
- ``name `` is the name of this Section, 'TheCrew' in the example case
345
346
- ``type `` provides the type of the Section, 'crew' in the example case
@@ -394,9 +395,9 @@ Let's have a look at the attributes for the Section 'TheCrew'::
394
395
>>> print(odmlEX['TheCrew'].definition)
395
396
Information on the crew
396
397
>>> print(odmlEX['TheCrew'].document)
397
- <Doc 42 by D. N. Adams ( 2 sections)>
398
+ Document 42 {author = D. N. Adams, 2 sections}
398
399
>>> print(odmlEX['TheCrew'].parent)
399
- <Doc 42 by D. N. Adams ( 2 sections)>
400
+ Document 42 {author = D. N. Adams, 2 sections}
400
401
>>> print(odmlEX['TheCrew'].type)
401
402
crew
402
403
>>> print(odmlEX['TheCrew'].reference)
@@ -414,27 +415,28 @@ To see which Sections are directly attached to the Section 'TheCrew' again use
414
415
the following command::
415
416
416
417
>>> print(odmlEX['TheCrew'].sections)
417
- [Section[0/ 5] {name = Arthur Philip Dent, type = crew/person, id = ...},
418
- Section[0/ 5] {name = Zaphod Beeblebrox, type = crew/person, id = ...},
419
- Section[0/ 5] {name = Tricia Marie McMillan, type = crew/person, id = ...},
420
- Section[0/ 5] {name = Ford Prefect, type = crew/person, id = ...}]
418
+ [Section[0| 5] {name = Arthur Philip Dent, type = crew/person, id = ...},
419
+ Section[0| 5] {name = Zaphod Beeblebrox, type = crew/person, id = ...},
420
+ Section[0| 5] {name = Tricia Marie McMillan, type = crew/person, id = ...},
421
+ Section[0| 5] {name = Ford Prefect, type = crew/person, id = ...}]
421
422
422
423
Or, for accessing these sub-Sections::
423
424
424
425
>>> print(odmlEX['TheCrew'].sections['Ford Prefect'])
425
- Section[0/ 5] {name = Ford Prefect, type = crew/person, id = ...}
426
+ Section[0| 5] {name = Ford Prefect, type = crew/person, id = ...}
426
427
>>> print(odmlEX['TheCrew'].sections[3])
427
- Section[0/ 5] {name = Ford Prefect, type = crew/person, id = ...}
428
+ Section[0| 5] {name = Ford Prefect, type = crew/person, id = ...}
428
429
>>> print(odmlEX['TheCrew']['Ford Prefect'])
429
- Section[0/ 5] {name = Ford Prefect, type = crew/person, id = ...}
430
+ Section[0| 5] {name = Ford Prefect, type = crew/person, id = ...}
430
431
>>> print(odmlEX['TheCrew'][3])
431
- Section[0/ 5] {name = Ford Prefect, type = crew/person, id = ...}
432
+ Section[0| 5] {name = Ford Prefect, type = crew/person, id = ...}
432
433
433
434
As you learned, besides sub-Sections, a Section can also have Properties
434
435
attached. Let's see which Properties are attached to the Section 'TheCrew'::
435
436
436
437
>>> print(odmlEX['TheCrew'].properties)
437
- [Property: {name = NameCrewMembers}, Property: {name = NoCrewMembers}]
438
+ [Property: {name = NameCrewMembers},
439
+ Property: {name = NoCrewMembers}]
438
440
439
441
The printout and attributes of a Property are explained in the next chapter.
440
442
@@ -518,7 +520,7 @@ Let's check which attributes were defined for the Property 'NoCrewMembers'::
518
520
>>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].definition)
519
521
Number of crew members
520
522
>>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].document)
521
- <Doc 42 by D. N. Adams ( 2 sections)>
523
+ Document 42 {author = D. N. Adams, 2 sections}
522
524
>>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].values)
523
525
[4]
524
526
>>> print(odmlEX['TheCrew'].properties['NoCrewMembers'].dtype)
@@ -586,7 +588,7 @@ You can check if your new Document contains actually what you created by using
586
588
some of the commands you learned before::
587
589
588
590
>>> MYodML
589
- >>> <Doc None by None ( 0 sections)>
591
+ >>> Document None {author = None, 0 sections}
590
592
591
593
As you can see, we created an "empty" Document where the version and the author
592
594
attributes are not defined and no section is yet attached. You will learn how to create
@@ -623,7 +625,7 @@ Check if your new Document contains actually all attributes now::
623
625
>>> print(MYodML.date)
624
626
1979-10-12
625
627
>>> print(MYodML.document)
626
- <Doc 42 by D. N. Adams ( 0 sections)>
628
+ Document 42 {author = D. N. Adams, 0 sections}
627
629
>>> print(MYodML.parent)
628
630
None
629
631
>>> print(MYodML.repository)
@@ -663,14 +665,14 @@ updated::
663
665
>>> MYodML.append(sec1)
664
666
665
667
>>> print(MYodML)
666
- <Doc 42 by Douglas Adams ( 1 sections)>
668
+ Document 42 {author = D. N. Adams, 1 sections}
667
669
>>> print(MYodML.sections)
668
- [Section[0/ 0] {name = TheCrew, type = crew, id = ...}]
670
+ [Section[0| 0] {name = TheCrew, type = crew, id = ...}]
669
671
670
672
>>> print(sec1.document)
671
- <Doc 42 by D. N. Adams ( 1 sections)>
673
+ Document 42 {author = D. N. Adams, 1 sections}
672
674
>>> print(sec1.parent)
673
- <Doc 42 by D. N. Adams ( 1 sections)>
675
+ Document 42 {author = D. N. Adams, 1 sections}
674
676
675
677
It is also possible to connect a Section directly to a parent object.
676
678
Let's try this with the next Section we create::
@@ -681,12 +683,12 @@ Let's try this with the next Section we create::
681
683
parent=sec1)
682
684
683
685
>>> print(sec2)
684
- Section[0/ 0] {name = Arthur Philip Dent, type = crew/person, id = ...}
686
+ Section[0| 0] {name = Arthur Philip Dent, type = crew/person, id = ...}
685
687
686
688
>>> print(sec2.document)
687
- <Doc 42 by D. N. Adams ( 1 sections)>
689
+ Document 42 {author = D. N. Adams, 1 sections}
688
690
>>> print(sec2.parent)
689
- [Section[1/ 0] {name = TheCrew, type = crew, id = ...}
691
+ [Section[1| 0] {name = TheCrew, type = crew, id = ...}
690
692
691
693
Note that all of our created Sections do not contain any Properties yet. Let's
692
694
see if we can change this...
@@ -751,9 +753,9 @@ automatically update its parent attribute::
751
753
>>> MYodML['TheCrew']['Arthur Philip Dent'].append(prop1)
752
754
753
755
>>> print(prop1.document)
754
- <Doc 42 by D. N. Adams ( 1 sections)>
756
+ Document 42 {author = D. N. Adams, 1 sections}
755
757
>>> print(prop1.parent)
756
- Section[0/ 1] {name = Arthur Philip Dent, type = crew/person, id = ...}
758
+ Section[0| 1] {name = Arthur Philip Dent, type = crew/person, id = ...}
757
759
758
760
Next, let us create a Property with multiple metadata entries::
759
761
0 commit comments