开发者

XSLT: select a node who starts with a predefined list of elements

We have in input an XML like following:

<R>
   <MT N="folder" V="Folder1\Subfolder1" />
   <MT N="folder" V="Folder2xx\Subfolder1" /开发者_Python百科>
   <MT N="folder" V="Folder3yyyy\Subfolder1" />
   <MT N="folder" V="Folder4zzzz\Subfolder1" />
</R>

In our XSLT that performs the display, the entry:

<xsl:value-of select="MT[@N='folder']/@V"/>

displays:

Folder1\Subfolder1 Folder2xx\Subfolder1 Folder3yyyy\Subfolder1 Folder4zzzz\Subfolder1

What we need to achieve is to select the unique entry who starts with a pre-defined configurable list of strings, e.g. if our pre-defined list is

Folder2xx, Folder18ppp, Folder212aaa

I would like to display as output only

Folder2xx\Subfolder1

The optimal thing would be even:

Folder2xx\Subfolder1 (linked 3 times)

but I would really appreciate help on the selection of the unique element. That is unfortunately too complex for my knowledge on XSLT, can someone please help? Our system supports XSLT 2.0 and XPATH 2.0

thanks a lot!

Mario


Use:

MT[@N='folder']
     /@V[substring-before(.,'\')
        =
         ('Folder2xx', 'Folder18ppp', 'Folder212aaa')
        ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜