您好,我正在尝试获取处理指令中的伪属性的值,并将该伪属性的值放入该处理的每个实例的键值中指令。使用使用属性中的处理指令的字符串值<xsl:key>
这样的处理指令的例子看起来像这样的XML内容:
<?uspc-assoc-workflow sws='C139995_131101' forum='2014/12' target='9S1' type='PCA'?>
我的模板的下面是一个例子。我只看到了使用实际属性的模板实例,但由于这是一个处理指令,因此我不能简单地使用@sws作为值,所以我尝试使用以下命令来捕获字符串中伪属性的值:
<xsl:key name="uspcassocworkflow" match="processing-instruction('uspc-assoc-workflow')" use="substring-before(substring-after(., 'sws="'), '"')"/>
此编程是否有效?
我有第二组处理指令的所谓USPC-最终添加这个样子:
<?uspc-end-add id='f104450-r0001' sws='C139995_131101' symbols='yes'?>
和模板来匹配它看起来像这样:
<xsl:template match="processing-instruction('uspc-end-add')" name="end_add">
<!-- Need to be able to get the key values of the uspc-assoc-workflow sws psudo attribute here below -->
<xsl:for-each select="key('uspcassocworkflow', '@sws')">
<!-- Then here I need to be able test if the variable value endswsnumber matches one of uspassocworkflow processing instructions key value -->
</xsl:for-each>
<xsl:variable name="id"><xsl:value-of select="substring-before(substring-after(., 'id="'), '"')"/></xsl:variable>
<xsl:variable name="endswsnumber"><xsl:value-of select="substring-before(substring-after(., 'sws="'), '"')"/></xsl:variable>
<xsl:variable name="symbol"><xsl:value-of select="substring-before(substring-after(., 'symbol="'), '"')"/></xsl:variable>
因此以上我正在尝试将这些关键值引入此模板,然后我想测试变量endswsnumber是否与uspc-assoc-workflow PI的其中一个关键值相匹配。如果他们是匹配的,并且一旦我有相应的uspc-assoc-workflow PI。我将测试相应的uspc-assoc-workflow psudo属性的值是否为“目标”,并为每个目标值输出不同的跨度。因此,如果相应的uspc-assoc-workflow的目标值是'9S1',如上例所示,如果值为'9S2',我将输出一个跨度html,并在html中输出不同的跨度。 “目标”psudo属性只有几个不同的值,所以我对每个属性都进行测试。
谢谢。
你不能用'@sws “无论如何!你必须认为它是一个字符串。此外,单引号用'''表示,而不是用'"'(用于双引号)。您是否可以通过完整的XSLT将您的问题最小化为只有一个期望的输出,并且我们可以对其进行更新以实现输出。 –
我可以使用和后匹配值'sws ='并在关闭“'”之前将其添加到uspc-end-add PI中相同的对应值,而不事先知道实际字符串的值? –
LearningandBurning