【发布时间】:2017-03-31 09:18:03
【问题描述】:
我需要通过 XSLT 处理以下(简化的;还有更多属性行)XML 文件:
<Collection Name="Columns" Type="OutputColumn">
<SubRecord>
<Property Name="Name">SID</Property>
<Property Name="SqlType">BigInt</Property>
<Property Name="Derivation">inputstream1.SID</Property>
<Property Name="Description">Main key</Property>
</SubRecord>
<SubRecord>
<Property Name="Name">name</Property>
<Property Name="SqlType">Char</Property>
<Property Name="Derivation">inputstream2.name</Property>
<Property Name="Description">Surname</Property>
</SubRecord>
<SubRecord>
<Property Name="Name">street</Property>
<Property Name="SqlType">Char</Property>
<Property Name="Derivation">inputstream1.streetname + inputstream1.number</Property>
<Property Name="Description">Full street</Property>
</SubRecord></Collection>
我现在需要知道两件事作为 XSLT 中的变量来决定在 if-Condition 中进一步做什么:
- 是否存在至少一个 SubRecord,其中 substring-after(Derivation, '.') 与兄弟属性“Name”匹配(就像在前两个 SubRecord 中一样)?
- 是否至少有一个 SubRecord 的 substring-after(Derivation, '.') 与兄弟属性“名称”不匹配(就像在第三个 SubRecord 中一样)?
我尝试通过 Xpath 使用 Count()-Functionality 执行此操作,但根本无法弄清楚如何与名称为“Name”的兄弟属性节点进行比较...我也愿意如果您知道 Count() 的替代方法,还有其他想法。
【问题讨论】:
-
您需要说明这是 XSLT 1.0、2.0 还是 3.0。它会影响答案。