mods 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/mods/nom_terminology.rb +445 -8
- data/lib/mods/reader.rb +3 -3
- data/lib/mods/record.rb +6 -7
- data/lib/mods/version.rb +1 -1
- data/spec/language_spec.rb +100 -73
- data/spec/location_spec.rb +269 -119
- data/spec/name_spec.rb +223 -197
- data/spec/origin_info_spec.rb +315 -190
- data/spec/part_spec.rb +411 -176
- data/spec/physical_description_spec.rb +120 -55
- data/spec/reader_spec.rb +76 -61
- data/spec/record_info_spec.rb +448 -206
- data/spec/record_spec.rb +192 -7
- data/spec/related_item_spec.rb +275 -124
- data/spec/subject_spec.rb +666 -339
- data/spec/title_spec.rb +204 -89
- data/spec/top_level_elmnts_simple_spec.rb +324 -145
- metadata +79 -98
data/README.rdoc
CHANGED
@@ -37,7 +37,7 @@ TODO: Write usage instructions here
|
|
37
37
|
|
38
38
|
== Releases
|
39
39
|
|
40
|
-
|
40
|
+
0.0.15 make namespace aware processing the default
|
41
41
|
0.0.14 don't lose xml encoding in reader.normalize_mods under jruby
|
42
42
|
0.0.13 really really fix removal of xsi:schemaLocation in jruby
|
43
43
|
0.0.12 fix failing jruby test
|
data/lib/mods/nom_terminology.rb
CHANGED
@@ -405,7 +405,7 @@ module Mods
|
|
405
405
|
end
|
406
406
|
|
407
407
|
# TARGET_AUDIENCE -----------------------------------------------------------------------
|
408
|
-
t.targetAudience :path => '
|
408
|
+
t.targetAudience :path => '/mods/targetAudience'
|
409
409
|
t._targetAudience :path => '//targetAudience' do |n|
|
410
410
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
411
411
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
@@ -464,22 +464,459 @@ module Mods
|
|
464
464
|
end # terminology
|
465
465
|
|
466
466
|
mods_ng_xml.nom!
|
467
|
-
|
468
467
|
mods_ng_xml
|
469
468
|
end # set_terminology_no_ns
|
470
469
|
|
471
470
|
|
472
|
-
# set the NOM terminology
|
471
|
+
# set the NOM terminology; WITH namespaces
|
472
|
+
# NOTES:
|
473
|
+
# 1. certain words, such as 'type' 'name' 'description' are reserved words in jruby or nokogiri
|
474
|
+
# when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
|
475
|
+
# (e.g. 'type_at' for @type) and a suffix of '_el' is added if it is an element.
|
476
|
+
# 2. the underscore prefix variant terms are a way of making subterms for a node available
|
477
|
+
# to any instance of said node and are not intended to be used externally
|
473
478
|
# @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (with namespaces)
|
474
479
|
def set_terminology_ns(mods_ng_xml)
|
475
|
-
mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS}) do |t|
|
480
|
+
mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS }) do |t|
|
476
481
|
|
477
|
-
|
482
|
+
# FIXME: may want to deal with camelcase vs. underscore in method_missing
|
478
483
|
|
479
|
-
|
480
|
-
|
481
|
-
|
484
|
+
# ABSTRACT -------------------------------------------------------------------------------
|
485
|
+
t.abstract :path => '/m:mods/m:abstract'
|
486
|
+
t._abstract :path => '//m:abstract' do |n|
|
487
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
488
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
489
|
+
end
|
490
|
+
|
491
|
+
# ACCESS_CONDITION -----------------------------------------------------------------------
|
492
|
+
t.accessCondition :path => '/m:mods/m:accessCondition'
|
493
|
+
t._accessCondition :path => '//m:accessCondition' do |n|
|
494
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
495
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
496
|
+
end
|
497
|
+
|
498
|
+
# CLASSIFICATION -------------------------------------------------------------------------
|
499
|
+
t.classification :path => '/m:mods/m:classification'
|
500
|
+
t._classification :path => '//m:classification' do |n|
|
501
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
502
|
+
n.edition :path => '@edition', :accessor => lambda { |a| a.text }
|
503
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
504
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
505
|
+
}
|
506
|
+
end
|
507
|
+
|
508
|
+
# EXTENSION ------------------------------------------------------------------------------
|
509
|
+
t.extension :path => '/m:mods/m:extension'
|
510
|
+
t._extension :path => '//m:extension' do |n|
|
511
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
512
|
+
end
|
513
|
+
|
514
|
+
# GENRE ----------------------------------------------------------------------------------
|
515
|
+
t.genre :path => '/m:mods/m:genre'
|
516
|
+
t._genre :path => '//m:genre' do |n|
|
517
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
518
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
519
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
520
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
521
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
522
|
+
}
|
523
|
+
end
|
524
|
+
|
525
|
+
# IDENTIIER ------------------------------------------------------------------------------
|
526
|
+
t.identifier :path => '/m:mods/m:identifier'
|
527
|
+
t._identifier :path => '//m:identifier' do |n|
|
528
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
529
|
+
n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
|
530
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
531
|
+
end
|
532
|
+
|
533
|
+
# LANGUAGE -------------------------------------------------------------------------------
|
534
|
+
t.language :path => '/m:mods/m:language'
|
535
|
+
t._language :path => '//m:language' do |n|
|
536
|
+
n.languageTerm :path => 'm:languageTerm'
|
537
|
+
n.code_term :path => 'm:languageTerm[@type="code"]'
|
538
|
+
n.text_term :path => 'm:languageTerm[@type="text"]'
|
539
|
+
n.scriptTerm :path => 'm:scriptTerm'
|
540
|
+
end
|
541
|
+
t._languageTerm :path => '//m:languageTerm' do |lt|
|
542
|
+
lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
543
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
544
|
+
lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
545
|
+
}
|
546
|
+
end # t.language
|
547
|
+
|
548
|
+
# LOCATION -------------------------------------------------------------------------------
|
549
|
+
t.location :path => '/m:mods/m:location'
|
550
|
+
t._location :path => '//m:location' do |n|
|
551
|
+
n.physicalLocation :path => 'm:physicalLocation' do |e|
|
552
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
553
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
554
|
+
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
555
|
+
}
|
556
|
+
end
|
557
|
+
n.shelfLocator :path => 'm:shelfLocator'
|
558
|
+
n.url :path => 'm:url' do |e|
|
559
|
+
e.dateLastAccessed :path => '@dateLastAccessed', :accessor => lambda { |a| a.text }
|
560
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
561
|
+
e.note :path => '@note', :accessor => lambda { |a| a.text }
|
562
|
+
e.access :path => '@access', :accessor => lambda { |a| a.text }
|
563
|
+
e.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
564
|
+
end
|
565
|
+
n.holdingSimple :path => 'm:holdingSimple'
|
566
|
+
n.holdingExternal :path => 'm:holdingExternal'
|
567
|
+
end # t.location
|
568
|
+
|
569
|
+
# NAME ------------------------------------------------------------------------------------
|
570
|
+
t.plain_name :path => '/m:mods/m:name'
|
571
|
+
t._plain_name :path => '//m:name' do |n|
|
572
|
+
Mods::Name::ATTRIBUTES.each { |attr_name|
|
573
|
+
if attr_name != 'type'
|
574
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
575
|
+
else
|
576
|
+
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
577
|
+
end
|
578
|
+
}
|
579
|
+
# elements
|
580
|
+
n.namePart :path => 'm:namePart' do |np|
|
581
|
+
np.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
582
|
+
end
|
583
|
+
n.displayForm :path => 'm:displayForm'
|
584
|
+
n.affiliation :path => 'm:affiliation'
|
585
|
+
n.description_el :path => 'm:description' # description is used by Nokogiri
|
586
|
+
n.role :path => 'm:role/m:roleTerm' do |r|
|
587
|
+
r.type_at :path => "@type", :accessor => lambda { |a| a.text }
|
588
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
589
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
590
|
+
}
|
591
|
+
end
|
592
|
+
end # t._plain_name
|
593
|
+
|
594
|
+
t.personal_name :path => '/m:mods/m:name[@type="personal"]'
|
595
|
+
t._personal_name :path => '//m:name[@type="personal"]' do |n|
|
596
|
+
n.family_name :path => 'm:namePart[@type="family"]'
|
597
|
+
n.given_name :path => 'm:namePart[@type="given"]'
|
598
|
+
n.termsOfAddress :path => 'm:namePart[@type="termsOfAddress"]'
|
599
|
+
n.date :path => 'm:namePart[@type="date"]'
|
600
|
+
end
|
601
|
+
|
602
|
+
t.corporate_name :path => '/m:mods/m:name[@type="corporate"]'
|
603
|
+
t._corporate_name :path => '//m:name[@type="corporate"]'
|
604
|
+
t.conference_name :path => '/m:mods/m:name[@type="conference"]'
|
605
|
+
t._conference_name :path => '//m:name[@type="conference"]'
|
606
|
+
|
607
|
+
# NOTE ---------------------------------------------------------------------------------
|
608
|
+
t.note :path => '/m:mods/m:note'
|
609
|
+
t._note :path => '//m:note' do |n|
|
610
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
611
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
612
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
613
|
+
end
|
614
|
+
|
615
|
+
# ORIGIN_INFO --------------------------------------------------------------------------
|
616
|
+
t.origin_info :path => '/m:mods/m:originInfo'
|
617
|
+
t._origin_info :path => '//m:originInfo' do |n|
|
618
|
+
n.place :path => 'm:place' do |e|
|
619
|
+
e.placeTerm :path => 'm:placeTerm' do |ee|
|
620
|
+
ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
621
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
622
|
+
ee.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
623
|
+
}
|
624
|
+
end
|
625
|
+
end
|
626
|
+
n.publisher :path => 'm:publisher'
|
627
|
+
Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |date_el|
|
628
|
+
n.send date_el, :path => "m:#{date_el}" do |d|
|
629
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
630
|
+
d.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
631
|
+
}
|
632
|
+
if date_el == 'dateOther'
|
633
|
+
d.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
634
|
+
end
|
635
|
+
end
|
636
|
+
}
|
637
|
+
n.edition :path => 'm:edition'
|
638
|
+
n.issuance :path => 'm:issuance'
|
639
|
+
n.frequency :path => 'm:frequency' do |f|
|
640
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
641
|
+
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
642
|
+
}
|
643
|
+
end
|
644
|
+
end # t.origin_info
|
645
|
+
|
646
|
+
# PART -----------------------------------------------------------------------------------
|
647
|
+
t.part :path => '/m:mods/m:part'
|
648
|
+
t._part :path => '//m:part' do |n|
|
649
|
+
# attributes
|
650
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
651
|
+
n.order :path => '@order', :accessor => lambda { |a| a.text }
|
652
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
653
|
+
# child elements
|
654
|
+
n.detail :path => 'm:detail' do |e|
|
655
|
+
# attributes
|
656
|
+
e.level :path => '@level', :accessor => lambda { |a| a.text }
|
657
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
658
|
+
# elements
|
659
|
+
e.number :path => 'm:number'
|
660
|
+
e.caption :path => 'm:caption'
|
661
|
+
e.title :path => 'm:title'
|
662
|
+
end
|
663
|
+
n.extent :path => 'm:extent' do |e| # TODO: extent is ordered in xml schema
|
664
|
+
# attributes
|
665
|
+
e.unit :path => '@unit', :accessor => lambda { |a| a.text }
|
666
|
+
# elements
|
667
|
+
e.start :path => 'm:start'
|
668
|
+
e.end :path => 'm:end'
|
669
|
+
e.total :path => 'm:total'
|
670
|
+
e.list :path => 'm:list'
|
671
|
+
end
|
672
|
+
n.date :path => 'm:date' do |e|
|
673
|
+
Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
|
674
|
+
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
675
|
+
}
|
676
|
+
end
|
677
|
+
n.text_el :path => 'm:text' do |e|
|
678
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
679
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
680
|
+
end
|
681
|
+
end # t._part
|
682
|
+
|
683
|
+
# PHYSICAL_DESCRIPTION -------------------------------------------------------------------
|
684
|
+
t.physical_description :path => '/m:mods/m:physicalDescription'
|
685
|
+
t._physical_description :path => '//m:physicalDescription' do |n|
|
686
|
+
n.digitalOrigin :path => 'm:digitalOrigin'
|
687
|
+
n.extent :path => 'm:extent'
|
688
|
+
n.form :path => 'm:form' do |f|
|
689
|
+
f.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
690
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
691
|
+
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
692
|
+
}
|
693
|
+
end
|
694
|
+
n.internetMediaType :path => 'm:internetMediaType'
|
695
|
+
n.note :path => 'm:note' do |nn|
|
696
|
+
nn.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
697
|
+
nn.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
698
|
+
end
|
699
|
+
n.reformattingQuality :path => 'm:reformattingQuality'
|
700
|
+
end
|
701
|
+
|
702
|
+
# RECORD_INFO --------------------------------------------------------------------------
|
703
|
+
t.record_info :path => '/m:mods/m:recordInfo'
|
704
|
+
t._record_info :path => '//m:recordInfo' do |n|
|
705
|
+
# attributes
|
706
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
707
|
+
Mods::LANG_ATTRIBS.each { |attr_name|
|
708
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
709
|
+
}
|
710
|
+
# child elements
|
711
|
+
n.recordContentSource :path => 'm:recordContentSource' do |r|
|
712
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
713
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
714
|
+
}
|
715
|
+
end
|
716
|
+
n.recordCreationDate :path => 'm:recordCreationDate' do |r|
|
717
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
718
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
719
|
+
}
|
720
|
+
end
|
721
|
+
n.recordChangeDate :path => 'm:recordChangeDate' do |r|
|
722
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
723
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
724
|
+
}
|
725
|
+
end
|
726
|
+
n.recordIdentifier :path => 'm:recordIdentifier' do |r|
|
727
|
+
r.source :path => '@source', :accessor => lambda { |a| a.text }
|
728
|
+
end
|
729
|
+
n.recordOrigin :path => 'm:recordOrigin'
|
730
|
+
n.languageOfCataloging :path => 'm:languageOfCataloging' do |r|
|
731
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
732
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
733
|
+
}
|
734
|
+
r.languageTerm :path => 'm:languageTerm'
|
735
|
+
r.scriptTerm :path => 'm:scriptTerm'
|
736
|
+
end
|
737
|
+
n.descriptionStandard :path => 'm:descriptionStandard' do |r|
|
738
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
739
|
+
r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
740
|
+
}
|
741
|
+
end
|
742
|
+
end # t._record_info
|
743
|
+
|
744
|
+
# RELATED_ITEM-------------------------------------------------------------------------
|
745
|
+
t.related_item :path => '/m:mods/m:relatedItem' do |n|
|
746
|
+
# attributes
|
747
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
748
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
749
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
750
|
+
# elements
|
751
|
+
n.abstract :path => 'abstract'
|
752
|
+
n.accessCondition :path => 'm:accessCondition'
|
753
|
+
n.classification :path => 'm:classification'
|
754
|
+
n.extension :path => 'm:extension'
|
755
|
+
n.genre :path => 'm:genre'
|
756
|
+
n.identifier :path => 'm:identifier'
|
757
|
+
n.language :path => 'm:language'
|
758
|
+
n.location :path => 'm:location'
|
759
|
+
n.name_el :path => 'm:name' # Note: 'name' is used by Nokogiri
|
760
|
+
n.personal_name :path => 'm:name[@type="personal"]'
|
761
|
+
n.corporate_name :path => 'm:name[@type="corporate"]'
|
762
|
+
n.conference_name :path => 'm:name[@type="conference"]'
|
763
|
+
n.note :path => 'm:note'
|
764
|
+
n.originInfo :path => 'm:originInfo'
|
765
|
+
n.part :path => 'm:part'
|
766
|
+
n.physicalDescription :path => 'm:physicalDescription'
|
767
|
+
n.recordInfo :path => 'm:recordInfo'
|
768
|
+
n.subject :path => 'm:subject'
|
769
|
+
n.tableOfContents :path => 'm:tableOfContents'
|
770
|
+
n.targetAudience :path => 'm:targetAudience'
|
771
|
+
n.titleInfo :path => 'm:titleInfo'
|
772
|
+
n.typeOfResource :path => 'm:typeOfResource'
|
773
|
+
end
|
774
|
+
|
775
|
+
# SUBJECT -----------------------------------------------------------------------------
|
776
|
+
t.subject :path => '/m:mods/m:subject'
|
777
|
+
t._subject :path => '//m:subject' do |n|
|
778
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
779
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
780
|
+
}
|
781
|
+
n.topic :path => 'm:topic' do |n1|
|
782
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
783
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
784
|
+
}
|
785
|
+
end
|
786
|
+
n.geographic :path => 'm:geographic' do |n1|
|
787
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
788
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
789
|
+
}
|
790
|
+
end
|
791
|
+
n.temporal :path => 'm:temporal' do |n1|
|
792
|
+
# date attributes as elements
|
793
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
794
|
+
n1.send attr_name, :path => "#{attr_name}"
|
795
|
+
}
|
796
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
797
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
798
|
+
}
|
799
|
+
# date attributes as attributes
|
800
|
+
Mods::DATE_ATTRIBS.each { |attr_name|
|
801
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
802
|
+
}
|
803
|
+
end
|
804
|
+
n.titleInfo :path => 'm:titleInfo' do |t1|
|
805
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
806
|
+
t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
807
|
+
}
|
808
|
+
end
|
809
|
+
# Note: 'name' is used by Nokogiri
|
810
|
+
n.name_el :path => 'm:name' do |t1|
|
811
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
812
|
+
t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
813
|
+
}
|
814
|
+
end
|
815
|
+
n.personal_name :path => 'm:name[@type="personal"]'
|
816
|
+
n.corporate_name :path => 'm:name[@type="corporate"]'
|
817
|
+
n.conference_name :path => 'm:name[@type="conference"]'
|
818
|
+
n.geographicCode :path => 'm:geographicCode' do |g|
|
819
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
820
|
+
g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
821
|
+
}
|
822
|
+
end
|
823
|
+
n.genre :path => 'm:genre' do |n1|
|
824
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
825
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
826
|
+
}
|
827
|
+
end
|
828
|
+
n.hierarchicalGeographic :path => 'm:hierarchicalGeographic' do |n1|
|
829
|
+
Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
|
830
|
+
n1.send elname, :path => "m:#{elname}"
|
831
|
+
}
|
832
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
833
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
834
|
+
}
|
835
|
+
end
|
836
|
+
n.cartographics :path => 'm:cartographics' do |n1|
|
837
|
+
n1.scale :path => 'm:scale'
|
838
|
+
n1.projection :path => 'm:projection'
|
839
|
+
n1.coordinates :path => 'm:coordinates'
|
840
|
+
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
|
841
|
+
n1.send elname, :path => "m:#{elname}"
|
842
|
+
}
|
843
|
+
end
|
844
|
+
n.occupation :path => 'm:occupation' do |n1|
|
845
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
846
|
+
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
847
|
+
}
|
848
|
+
end
|
849
|
+
end # t.subject
|
850
|
+
|
851
|
+
# TABLE_OF_CONTENTS ---------------------------------------------------------------------
|
852
|
+
t.tableOfContents :path => '/m:mods/m:tableOfContents'
|
853
|
+
t._tableOfContents :path => '//m:tableOfContents' do |n|
|
854
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
855
|
+
n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
|
856
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
857
|
+
end
|
858
|
+
|
859
|
+
# TARGET_AUDIENCE -----------------------------------------------------------------------
|
860
|
+
t.targetAudience :path => '/m:mods/m:targetAudience'
|
861
|
+
t._targetAudience :path => '//m:targetAudience' do |n|
|
862
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
863
|
+
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
864
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
865
|
+
}
|
866
|
+
end
|
867
|
+
|
868
|
+
# TITLE_INFO ----------------------------------------------------------------------------
|
869
|
+
t.title_info :path => '/m:mods/m:titleInfo'
|
870
|
+
t._title_info :path => '//m:titleInfo' do |n|
|
871
|
+
Mods::TitleInfo::ATTRIBUTES.each { |attr_name|
|
872
|
+
if attr_name != 'type'
|
873
|
+
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
874
|
+
else
|
875
|
+
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
876
|
+
end
|
877
|
+
}
|
878
|
+
n.title :path => 'm:title'
|
879
|
+
n.subTitle :path => 'm:subTitle'
|
880
|
+
n.nonSort :path => 'm:nonSort'
|
881
|
+
n.partNumber :path => 'm:partNumber'
|
882
|
+
n.partName :path => 'm:partName'
|
883
|
+
n.sort_title :path => '.', :accessor => lambda { |node|
|
884
|
+
if node.type_at != "alternative" || (node.type_at == "alternative" &&
|
885
|
+
mods_ng_xml.xpath('/m:mods/m:titleInfo', {'m' => Mods::MODS_NS}).size == 1)
|
886
|
+
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
887
|
+
end
|
888
|
+
}
|
889
|
+
n.full_title :path => '.', :accessor => lambda { |node|
|
890
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
891
|
+
node.title.text +
|
892
|
+
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
893
|
+
}
|
894
|
+
n.short_title :path => '.', :accessor => lambda { |node|
|
895
|
+
if node.type_at != "alternative"
|
896
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
897
|
+
node.title.text
|
898
|
+
end
|
899
|
+
}
|
900
|
+
n.alternative_title :path => '.', :accessor => lambda { |node|
|
901
|
+
if node.type_at == "alternative"
|
902
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
903
|
+
node.title.text
|
904
|
+
end
|
905
|
+
}
|
906
|
+
end # t._title_info
|
907
|
+
|
908
|
+
# TYPE_OF_RESOURCE --------------------------------------------------------------------
|
909
|
+
t.typeOfResource :path => '/m:mods/m:typeOfResource'
|
910
|
+
t._typeOfResource :path => '//m:typeOfResource' do |n|
|
911
|
+
n.collection :path => '@collection', :accessor => lambda { |a| a.text }
|
912
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
913
|
+
n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
|
914
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
915
|
+
end
|
916
|
+
|
917
|
+
end # terminology
|
482
918
|
|
919
|
+
mods_ng_xml.nom!
|
483
920
|
mods_ng_xml
|
484
921
|
end # set_terminology_ns
|
485
922
|
|