来自XMLTYPE列的Oracle JPG元数据xpath

时间:2012-12-03 14:06:17

标签: oracle xpath extract exif multimedia

我有一个很好的存储照片。使用pl / sql脚本,我将图像元数据提取到exifmetadata xmltype列。 我想逐个选择元素,但我总是得到null,我不知道我的xpath表达式有什么问题。

    <exifMetadata xmlns="http://xmlns.oracle.com/ord/meta/exif" xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/exif http://xmlns.oracle.com/ord/meta/exif" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <TiffIfd>
      <Make tag="271">Apple</Make>
      <Model tag="272">iPhone 4S</Model>
      <Orientation tag="274">top left</Orientation>
      <XResolution tag="282">72.0</XResolution>
      <YResolution tag="283">72.0</YResolution>
      <ResolutionUnit tag="296">inches</ResolutionUnit>
      <Software tag="305">6.0.1</Software>
      <DateTime tag="306">2012-11-16T13:31:15</DateTime>
      <YCbCrPositioning tag="531">centered</YCbCrPositioning>
   </TiffIfd>
   <ExifIfd tag="34665">
      <ExposureTime tag="33434">0.004405286</ExposureTime>
      <FNumber tag="33437">2.4</FNumber>
      <ExposureProgram tag="34850">Normal program</ExposureProgram>
      <ExifVersion tag="36864">0221</ExifVersion>
      <DateTimeOriginal tag="36867">2012-11-16T12:49:58</DateTimeOriginal>
      <DateTimeDigitized tag="36868">2012-11-16T12:49:58</DateTimeDigitized>
      <ComponentsConfiguration tag="37121">Y</ComponentsConfiguration>
      <ShutterSpeedValue tag="37377">7.82697</ShutterSpeedValue>
      <ApertureValue tag="37378">2.5260692</ApertureValue>
      <BrightnessValue tag="37379">6.641153</BrightnessValue>
      <MeteringMode tag="37383">Pattern</MeteringMode>
      <Flash tag="37385">
         <Fired>No</Fired>
      </Flash>
      <FocalLength tag="37386">4.28</FocalLength>
      <FlashpixVersion tag="40960">0100</FlashpixVersion>
      <ColorSpace tag="40961">sRGB</ColorSpace>
      <PixelXDimension tag="40962">2902</PixelXDimension>
      <PixelYDimension tag="40963">1938</PixelYDimension>
      <SensingMethod tag="41495">One-chip color area</SensingMethod>
      <ExposureMode tag="41986">Auto exposure</ExposureMode>
      <WhiteBalance tag="41987">Auto</WhiteBalance>
      <FocalLengthIn35mmFilm tag="41989">35</FocalLengthIn35mmFilm>
      <SceneCaptureType tag="41990">Standard</SceneCaptureType>
   </ExifIfd>
</exifMetadata>

和SQL:

    SELECT 
  p.metaexif.extract('//exifMetadata/TiffIfd/Make/text()').getStringVal() "Model" 
  FROM scott.photos p
  WHERE id=22
  ;

存在肯定的id 22记录。

1 个答案:

答案 0 :(得分:1)

你有一个默认的命名空间,所以你必须处理这个。

例如使用:

select extractvalue(p.metaexif,'/exifMetadata/TiffIfd/Make',
        'xmlns="http://xmlns.oracle.com/ord/meta/exif"')
相关问题