Parse text file with XSLT

后端 未结 2 1594
一整个雨季
一整个雨季 2021-01-05 03:15

I have a plain text file structured like this:

!ITEM_NAME
Item value
!ANOTHER_ITEM
Its value
...

Is it possible to get with XSLT a file sim

2条回答
  •  隐瞒了意图╮
    2021-01-05 04:14

    This XSLT 2.0 transformation:

    
     
    
     
    
     
      
          
           
             
                    
             
           
           
          
      
     
    
    

    when appliedon any XML document (not used) and having the provided text residing in the local file C:\temp\delete\Text.txt:

    !ITEM_NAME
    Item value
    !ANOTHER_ITEM
    Its value
    ...
    

    produces the wanted, correct result:

    
       Item value
       Its value
    ...
    
    

    To test more completely, we put this text in the file:

    As is text
    !ITEM_NAME
    Item value
    !ANOTHER_ITEM
    Its value
    As is text2
    !TEST_BANG
    Here's a value with !bangs!!!
    !TEST2_BANG
     !!!Here's a value with !more~ !bangs!!!
    As is text3
    

    The transformation again produces the wanted, correct result:

    As is text
    Item value
    Its value
    As is text2
    Here's a value with !bangs!!!
     !!!Here's a value with !more~ !bangs!!!
    As is text3
    
    

提交回复
热议问题