1

我会写什么测试来查看给定记录的 thumbnailURL 属性是否存在?

<record last-modified="Wed, 16 Oct 2013 13:07:24 EDT" mimetype="text/html" url="someURL">
<metadata>
  <meta content="Planning" name="title"/>
  <meta content="12345" name="ccsid"/>
  <meta content="user1234" name="author"/>
  <meta content="Wed Oct 16 13:07:24 EDT 2013" name="pubDate"/>
  <meta content="planning" name="categories"/>
  <meta content="http://thumbnail_182x136.jpg" name="thumbnailURL"/>
</metadata>
<content>
Some description
</content>
</record>
4

1 回答 1

1

If the current context node is the record element then something like

metadata/meta[@name = 'thumbnailURL']

should do the job. Evaluated as boolean (e.g. in the test of an xsl:if) this would be true if the thumbnailURL meta element exists and false if it doesn't, evaluated as a node set (e.g. in the select of an xsl:variable) it would give you the set of all meta elements under the record whose name is thumbnailURL or an empty set if there are none.

于 2013-10-21T13:32:49.547 回答