我需要使用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
但我只提取了第一个点形状
有什么解决办法吗?
我的猜测是,您的工具正在将XPath的结果转换为字符串,即它正在执行相当于的操作
string(/xmpmeta/RDF/Description/inks/Seq/li/dotshape)
当XPath被转换成这样的字符串时,您只能返回第一个匹配项。
您应该在正在使用的工具的API中查找其他类型的调用,该调用返回节点集或节点列表,而不是字符串或标量值。