hvelucha
6/17/2015 - 4:17 AM

Jesse_xpath.sql

Copy(select internal_id, object_id, (xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:rights/lom:cost/lom:value/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text costValue,

(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:rights/lom:copyrightAndOtherRestrictions/lom:value/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text copyrightAndOtherRestrictions


from available_objects  order by object_id desc limit 50) To 'C:/<filepath>/Notes1.csv' CSV
;


select internal_id, object_id,(xpath('/imscp:manifest/imscp:resources/imscp:resource/imscp:file/@href', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text resource_list
select  object_id, name, learning_areas,
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:classification/lom:taxonPath/lom:taxon/lom:entry[lom:string="Performing arts"]/lom:string/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ])) :: text

from available_objects
where (object_id like 'S%' or object_id like 'L%' or object_id like 'R%')
and
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:classification/lom:taxonPath/lom:taxon/lom:entry[lom:string="Performing arts"]/lom:string/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ])) :: text like '%Performing arts%'
order by object_id
--Thanks for this. Very helpful  I was able to validate that the field available_objects.resource_type is the same as the metadata field learningResourceType in the manifest file. 
--Sharing my queries:

select internal_id, object_id, 
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:educational/lom:learningResourceType/lom:value/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text learningResourceType

from available_objects
where (xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:educational/lom:learningResourceType/lom:value/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text like '%Sound%'
or
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:educational/lom:learningResourceType/lom:value/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ]))[1]:: text like '%Moving%'

Same as

select object_id, name, resource_type, start_file
from  available_objects
where (resource_type like '%Moving%' or resource_type like '%Sound%')




select internal_id, object_id, 
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:classification/lom:taxonPath/lom:taxon/lom:entry[lom:string="Studies of Society and Environment"]/lom:string/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ])) :: text

from available_objects
where object_id like 'S%'
and
(xpath('/imscp:manifest/imscp:metadata/lom:lom/lom:classification/lom:taxonPath/lom:taxon/lom:entry[lom:string="Studies of Society and Environment"]/lom:string/text()', manifest::xml, ARRAY[ARRAY['lom', 'http://ltsc.ieee.org/xsd/LOM'],
ARRAY['imscp', 'http://www.imsglobal.org/xsd/imscp_v1p1'] ])) :: text like '%Studies of Society and Environment%'
order by object_id