xslt - 如何检查特定属性是否存在于 XML 中的所有子节点中?
问题描述
如何检查 XML 中的所有子节点中是否存在特定属性?例如,我想检查 ws:Status 的所有子节点中是否存在 ws:PriorValue ?
<ws:Status>
<ws:Staffing_Event ws:PriorValue="">LOA</ws:Staffing_Event>
<ws:Staffing_Event_Date ws:PriorValue="">2020-05-01</ws:Staffing_Event_Date>
<ws:Employee_Status ws:PriorValue="Active">OnLeave</ws:Employee_Status>
<ws:Active ws:PriorValue="true">false</ws:Active>
<ws:Hire_Date>2000-01-01</ws:Hire_Date>
</ws:Status>
解决方案
你可以这样做:
<xsl:template match="ws:Status">
<test>
<xsl:if test="*[not(@ws:PriorValue)]">Not all child elements have a PriorValue attribute</xsl:if>
</test>
</xsl:template>
推荐阅读
- svelte - Svelte - 使用绑定在一起的两个输入来控制单个商店项目
- javascript - Java脚本,节点js函数没有返回预期的内容
- java - 从其他类调用方法时出现类循环问题
- r - 从具有多个坐标的数据框创建 sf 对象 | 顺丰
- excel - Excel 连续工作天数至少 60 分钟
- database - 续集,创建新用户并在一个查询中分配已创建的角色?
- python - 将具有“int”“类型”的变量放入方法的参数即“.remove()”时获取“未知变量x”或“ValueError”
- node.js - Puppeteer 不能在 Google App Engine 中工作?
- c# - 如何从 Azure 表存储中查询最近的 n 条记录?
- verilog - 为什么这个 Verilog 模块在第 9 行显示“无效模块项”?