ShellShoccar-jpn / Parsrs

CSV, JSON, XML text parsers and generators written in pure POSIX shellscript
The Unlicense
80 stars 12 forks source link

makrx.sh broken? #8

Open Tpaefawzen opened 5 months ago

Tpaefawzen commented 5 months ago

Version

[_@_ ~]$ parsrx.sh --version
Usage   : parsrx.sh [options] [XML_file]
Options : -c  Print the child tags in value explicitly
          -n  Print the array subscript number after the tag name
          -lf Replace the newline sign "\n" with <s>. 
              This option disables replacing \ with \\.
Environs: LINE_BUFFERED
            =yes ........ Line-buffered mode if possible
            =forcible ... Force line-buffered mode. Exit if unavailable.
Version : 2022-02-06 12:45:01 JST
          (POSIX Bourne Shell/POSIX commands)
[_@_ ~]$ makrx.sh --version
Usage   : makrx.sh [XPath-value_textfile]
Version : 2020-05-06 22:42:19 JST
          (POSIX Bourne Shell/POSIX commands)
[_@_ ~]$ 

Test 1

[_@_ ~]$ cat __.xml 
<?xml version="1.0" encoding="UTF-8"?>
<foo>
  Great!Awsome!
  <bar bar="BAR" foo="FOO">Wow!<br /><script /></bar>
</foo>
[_@_ ~]$ parsrx.sh __.xml 
/foo/bar/@bar BAR
/foo/bar/@foo FOO
/foo/bar/br
/foo/bar/script
/foo/bar Wow!
/foo \n Great!Awsome!\n \n
[_@_ ~]$ parsrx.sh __.xml | makrx.sh  # Missing <foo>
<?xml version="1.0" encoding="UTF-8"?><bar bar="BAR" foo="FOO">Wow!<br /><script /></bar></foo>

[_@_ ~]$ parsrx.sh __.xml | makrx.sh | parsrx.sh 
/bar/@bar BAR
/bar/@foo FOO
/bar/br
/bar/script
/bar Wow!
 ?xml version="1.0" encoding="UTF-8"?>
[_@_ ~]$ 

Supposed output

$ parsrx.sh __.xml | makrx.sh
<?xml version="1.0" encoding="UTF-8"?><foo><bar bar="BAR" foo="FOO">Wow!<br /><script /></bar></foo>

$ 

Test 2

Taken from here

[_@_ ~]$ cat >__r.xml
<root>
  <personal>
    <![CDATA[toward independent taken locate whose]]>
    <safety>meant</safety>
    <pale name="fur">1227235817.5203295</pale>
    <wash>
      <![CDATA[balloon select opinion seed if wheat difficult pleasure eventually dance sunlight favorite course respect]]>electric
    </wash>
  </personal>
  <![CDATA[between grade somewhere vertical foot unknown arrow handle weak]]>
  <cross pair="bus">other</cross>
  <![CDATA[once announced program fewer]]>
  <moment writer="light">trade</moment>
</root>
[_@_ ~]$ parsrx.sh __r.xml 
/root/personal/safety meant
/root/personal/pale/@name fur
/root/personal/pale 1227235817.5203295
/root/personal/wash \n     <![CDATA[balloon select opinion seed if wheat difficult pleasure eventually dance sunlight favorite course respect]]>electric\n   
/root/personal \n   <![CDATA[toward independent taken locate whose]]>\n   \n   \n   \n 
/root/cross/@pair bus
/root/cross other
/root/moment/@writer light
/root/moment trade
/root \n \n <![CDATA[between grade somewhere vertical foot unknown arrow handle weak]]>\n \n <![CDATA[once announced program fewer]]>\n \n
[_@_ ~]$ parsrx.sh __r.xml | makrx.sh # Missing <root>, <personal>, <wash>, and <![CDATA[....]]>.
<?xml version="1.0" encoding="UTF-8"?><cross pair="bus">other</cross><moment writer="light">trade</moment><pale name="fur">1227235817.5203295</pale><safety>meant</safety></personal></root>

[_@_ ~]$ parsrx.sh __r.xml | makrx.sh | parsrx.sh 
/cross/@pair bus
/cross other
/moment/@writer light
/moment trade
/pale/@name fur
/pale 1227235817.5203295
/safety meant
 ?xml version="1.0" encoding="UTF-8"?>

[_@_ ~]$ 
colrichie commented 5 months ago

Sorry, the command "makrx.sh" doesn't work correctly yet because the author of the command quit this project in the middle of development.