Selecting all text nodes in between two processing instructions with XPATH

后端 未结 1 1131
面向向阳花
面向向阳花 2021-01-28 02:21

I have some following XML:


  

test test test

1条回答
  •  情歌与酒
    2021-01-28 03:20

    I recommend using xal:for-each-group as suggested in the first comment by Maring Honnen. The other XPath approaches allow you to select the content between two processing instructions, but it will be hard to embed that in an xslt stylesheet that should do other things as well, like copying existing structure at the same time. Here a minimal approach using for-each-group:

    xquery version "1.0-ml";
    
    let $xml :=
      
        

    before test test test after

    let $xsl := return xdmp:xslt-eval($xsl, $xml)

    Use a second for-each-group with group-ending-by as suggested by Martin if you like to get the end PI inside the tag. The above might be sufficient though.

    HTH!

    0 讨论(0)
提交回复
热议问题