从XMP中提取所有值

时间:2012-03-30 07:08:13

标签: xpath xmp

我需要使用XPATH表达式从XMP文件中提取一些信息 我有一个像这样的XMP文件:

    <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0">
       <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
          <rdf:Description xmlns:egPDFNat="http://ns.esko-graphics.com/pdfnatversion/1.0/" rdf:about="">
             <egPDFNat:version>201</egPDFNat:version>
             <egPDFNat:flexripversion>700</egPDFNat:flexripversion>
          </rdf:Description>
          <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="">
             <xmp:CreateDate>2012-03-29T14:40:40+02:00</xmp:CreateDate>
             <xmp:CreatorTool>ArtPro 10.1 rev 2 build 56 (2011-12-01)</xmp:CreatorTool>
             <xmp:MetadataDate>2012-03-29T14:40:40+02:00</xmp:MetadataDate>
             <xmp:ModifyDate>2012-03-29T14:40:40+02:00</xmp:ModifyDate>
          </rdf:Description>
          <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="">
             <dc:description>
                <rdf:Alt>
                   <rdf:li xml:lang="x-default">ArtPro Normalized PDF</rdf:li>
                </rdf:Alt>
             </dc:description>
          </rdf:Description>
          <rdf:Description xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/" rdf:about="">
             <egGr:nrpages>1</egGr:nrpages>
             <egGr:units>mm</egGr:units>
             <egGr:vsize>150</egGr:vsize>
             <egGr:hsize>150</egGr:hsize>
             <egGr:margtop>0</egGr:margtop>
             <egGr:margbot>0</egGr:margbot>
             <egGr:margleft>0</egGr:margleft>
             <egGr:margright>0</egGr:margright>
             <egGr:vshrink>1</egGr:vshrink>
             <egGr:hshrink>1</egGr:hshrink>
             <egGr:readerspread>False</egGr:readerspread>
             <egGr:inks>
                <rdf:Seq>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>cyan</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Cyan</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>15</egInk:angle>
                      <egInk:dotshape>CS19</egInk:dotshape>
                      <egInk:r>0</egInk:r>
                      <egInk:g>0.560784314</egInk:g>
                      <egInk:b>0.858823529</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>cyan</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Cyan</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>15</egInk:angle>
                      <egInk:dotshape>HD01</egInk:dotshape>
                      <egInk:r>0</egInk:r>
                      <egInk:g>0.560784314</egInk:g>
                      <egInk:b>0.858823529</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>cyan</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Cyan</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>15</egInk:angle>
                      <egInk:dotshape>C</egInk:dotshape>
                      <egInk:r>0</egInk:r>
                      <egInk:g>0.560784314</egInk:g>
                      <egInk:b>0.858823529</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>cyan</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Cyan</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>15</egInk:angle>
                      <egInk:dotshape>SCR01</egInk:dotshape>
                      <egInk:r>0</egInk:r>
                      <egInk:g>0.560784314</egInk:g>
                      <egInk:b>0.858823529</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>magenta</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Magenta</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>75</egInk:angle>
                      <egInk:dotshape>CS19</egInk:dotshape>
                      <egInk:r>0.760784314</egInk:r>
                      <egInk:g>0</egInk:g>
                      <egInk:b>0.349019608</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>magenta</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Magenta</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>75</egInk:angle>
                      <egInk:dotshape>HD01</egInk:dotshape>
                      <egInk:r>0.760784314</egInk:r>
                      <egInk:g>0</egInk:g>
                      <egInk:b>0.349019608</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>magenta</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Magenta</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>75</egInk:angle>
                      <egInk:dotshape>C</egInk:dotshape>
                      <egInk:r>0.760784314</egInk:r>
                      <egInk:g>0</egInk:g>
                      <egInk:b>0.349019608</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                   <rdf:li rdf:parseType="Resource">
                      <egInk:name>magenta</egInk:name>
                      <egInk:type>process</egInk:type>
                      <egInk:book>process</egInk:book>
                      <egInk:egname>Magenta</egInk:egname>
                      <egInk:frequency>150</egInk:frequency>
                      <egInk:angle>75</egInk:angle>
                      <egInk:dotshape>SCR01</egInk:dotshape>
                      <egInk:r>0.760784314</egInk:r>
                      <egInk:g>0</egInk:g>
                      <egInk:b>0.349019608</egInk:b>
                      <egInk:attribute>normal</egInk:attribute>
                   </rdf:li>
                </rdf:Seq>
             </egGr:inks>
      </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>

我想提取所有 dotshape 值(无论如何都用空格,斜线,逗号....) 我试过了:

/xmpmeta/RDF/Description/inks/Seq/li/dotshape

但我只提取了第一个圆点形状 有没有解决方案?

1 个答案:

答案 0 :(得分:0)

我的猜测是你的工具正在将XPath的结果转换为字符串 - 即它正在做相当于

string(/xmpmeta/RDF/Description/inks/Seq/li/dotshape)

当XPath转换为这样的字符串时,您只返回第一个匹配项。

您应该查看正在使用的工具的API,以用于返回节点集或节点列表而不是字符串或标量值的其他类型的调用。