连接来自在XSLT中用/分隔的相同标签的值

时间:2017-11-23 16:46:20

标签: xml xslt

我的XML是:

<_path>
      <objekttyp level="0" parent-level="3">
        <_system_object_id>252</_system_object_id>
        <_global_object_id>252@33a8cae1-a9fa-4655-8c3d-b71241bbc99b</_global_object_id>
        <_uuid>4c5b995c-32b5-45c0-8ad4-8f5c3964bcdb</_uuid>
        <_id>220</_id>
        <_objecttype>objekttyp</_objecttype>
        <_standard>
          <de-DE>ertgretgere</de-DE>
        </_standard>
      </objekttyp>
      <objekttyp level="1" parent-level="2">
        <_system_object_id>486</_system_object_id>
        <_global_object_id>486@33a8cae1-a9fa-4655-8c3d-b71241bbc99b</_global_object_id>
        <_uuid>622dd5f3-a778-4eb4-8d21-531263727772</_uuid>
        <_id>391</_id>
        <_objecttype>objekttyp</_objecttype>
        <_standard>
          <de-DE>regtetr</de-DE>
        </_standard>
      </objekttyp>

    </_path>

我需要提取每个&lt; _system_object_id&gt;并通过/分隔它们。我已经尝试了两个以下选项,但它不起作用。 This is the result <dc:ispartof>252486</dc:ispartof>

<dc:ispartof>
          <xsl:for-each select="/_path"/>

<xsl:value-of select="_system_object_id" separator="'/'"/>  

        <xsl:value-of select="concat(_system_object_id,'/',_system_object_id)"/>     
        </xsl:for-each>

     </dc:ispartof>

1 个答案:

答案 0 :(得分:1)

如果您在样式表中使用XSLT 2或更高版本的处理器以及version="2.0"或更高版本的处理器,那么执行<xsl:value-of select="//_system_object_id" separator="/"/>应该这样做,而不是您xsl:value-of所在的模板。

在您的<xsl:for-each select="/_path"/>内,您可以使用上述建议,或者如果您想要相对路径,那么<xsl:value-of select="objekttyp/_system_object_id" separator="/"/>应该选择示例输入中的元素。