(command.CommandList
  children: [
    (command.ShFunction
      name: usage
      body: 
        (BraceGroup
          children: [
            (command.Sentence child:(C {<echo>} {(SQ )}) terminator:<Id.Op_Semi _>)
            (command.Sentence
              child: (C {<echo>} {(SQ <'Usage: xmlproc.sh -[option] <filename.xml>'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (C {<echo>} {(SQ <'Specify a target from:'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (C {<echo>} {(SQ <'-v      verify xml file conforms to dtd'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (C {<echo>} {(SQ <'-html   output in html format (single file)'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (C {<echo>} {(SQ <'-ps     output in postscript format'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (C {<echo>} {(SQ <'-pdf    output in pdf format'>)})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (command.ControlFlow token:<Id.ControlFlow_Exit exit>)
              terminator: <Id.Op_Semi _>
            )
          ]
        )
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: (C {<test>} {($ Id.VSub_Pound '$#')} {<-ne>} {<2>})
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [(C {<usage>})]
          spids: [75 86]
        )
      ]
    )
    (command.CommandList
      children: [
        (command.Sentence
          child: 
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:action)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [96]
                )
              ]
            )
          terminator: <Id.Op_Semi _>
        )
        (C {<shift>})
      ]
    )
    (command.CommandList
      children: [
        (command.Sentence
          child: 
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:xmlfile)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [105]
                )
              ]
            )
          terminator: <Id.Op_Semi _>
        )
        (C {<shift>})
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C 
                      {
                        (word_part.ExtGlob
                          op: <Id.ExtGlob_Bang '!('>
                          arms: [{<'test -f '> ($ Id.VSub_DollarName '$xmlfile')}]
                        )
                      }
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.Sentence
              child: (C {<echo>} {(DQ <'No such file: '> ($ Id.VSub_DollarName '$xmlfile'))})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (command.ControlFlow token:<Id.ControlFlow_Exit exit>)
              terminator: <Id.Op_Semi _>
            )
          ]
          spids: [114 122]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OUT)
          op: assign_op.Equal
          rhs: {<output>}
          spids: [142]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:xsl_fo)
          op: assign_op.Equal
          rhs: {<bz-fo.xsl>}
          spids: [145]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:xsl_html)
          op: assign_op.Equal
          rhs: {<bz-html.xsl>}
          spids: [148]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:basename)
          op: assign_op.Equal
          rhs: {($ Id.VSub_DollarName '$xmlfile')}
          spids: [152]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:basename)
          op: assign_op.Equal
          rhs: 
            {
              (braced_var_sub
                token: <Id.VSub_Name basename>
                suffix_op: 
                  (suffix_op.PatSub
                    pat: {(SQ <.xml>)}
                    replace: {(SQ )}
                    replace_mode: Id.Lit_Slash
                  )
              )
            }
          spids: [155]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:fofile)
          op: assign_op.Equal
          rhs: {(DQ (${ Id.VSub_Name basename) <.fo>)}
          spids: [169]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:htmlfile)
          op: assign_op.Equal
          rhs: {(DQ (${ Id.VSub_Name basename) <.html>)}
          spids: [177]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:pdffile)
          op: assign_op.Equal
          rhs: {(DQ (${ Id.VSub_Name basename) <.pdf>)}
          spids: [185]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:psfile)
          op: assign_op.Equal
          rhs: {(DQ (${ Id.VSub_Name basename) <.ps>)}
          spids: [193]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:xmlfmtfile)
          op: assign_op.Equal
          rhs: {(DQ (${ Id.VSub_Name basename) <.fmt>)}
          spids: [201]
        )
      ]
    )
    (C {<'./format.pl'>} {($ Id.VSub_DollarName '$xmlfile')} {($ Id.VSub_DollarName '$xmlfmtfile')})
    (C {<export>} {<Id.Lit_VarLike 'XML_CATALOG_FILES='> <'/etc/xml/catalog'>})
    (command.ShFunction
      name: cleanup
      body: 
        (BraceGroup
          children: [
            (C {<echo>} {(DQ <'Cleaning up: # '> ($ Id.VSub_At '$@'))})
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: 
                (condition.Shell
                  commands: [
                    (C {<Id.Lit_LBracket '['>} {($ Id.VSub_Pound '$#')} 
                      {<Id.KW_Bang '!'> <Id.Lit_Equals '='>} {<0>} {<Id.Lit_RBracket ']'>}
                    )
                  ]
                )
              body: 
                (command.DoGroup
                  children: [
                    (command.Sentence
                      child: 
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:arg)
                              op: assign_op.Equal
                              rhs: {($ Id.VSub_Number '$1')}
                              spids: [264]
                            )
                          ]
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (C {<shift>})
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: (C {<echo>} {(DQ <'  deleting '> ($ Id.VSub_DollarName '$arg'))})
                      terminator: <Id.Op_Semi _>
                    )
                    (C {<rm>} {($ Id.VSub_DollarName '$arg')})
                  ]
                )
            )
          ]
        )
    )
    (command.Case
      to_match: {($ Id.VSub_DollarName '$action')}
      arms: [
        (case_arm
          pat_list: [{<-v>}]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:flags)
                  op: assign_op.Equal
                  rhs: {(SQ <'--noout --xinclude --noblanks --postvalid'>)}
                  spids: [302]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:dtd)
                  op: assign_op.Equal
                  rhs: {(SQ <'--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'>)}
                  spids: [308]
                )
              ]
            )
            (command.Simple
              words: [
                {<xmllint>}
                {($ Id.VSub_DollarName '$flags')}
                {($ Id.VSub_DollarName '$dtd')}
                {($ Id.VSub_DollarName '$xmlfmtfile')}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_Great '2>'>
                  loc: (redir_loc.Fd fd:2)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
              ]
              do_fork: T
            )
            (C {<egrep>} {(SQ <error>)} {($ Id.VSub_DollarName '$OUT')})
            (C {<rm>} {($ Id.VSub_DollarName '$OUT')})
          ]
          spids: [298 299 343 -1]
        )
        (case_arm
          pat_list: [{<-html>}]
          action: [
            (C {<echo>} {(DQ <'Creating '> ($ Id.VSub_DollarName '$htmlfile') <' ...'>)})
            (C {<xsltproc>} {<--nonet>} {<--xinclude>} {<-o>} {($ Id.VSub_DollarName '$htmlfile')} 
              {($ Id.VSub_DollarName '$xsl_html')} {($ Id.VSub_DollarName '$xmlfmtfile')}
            )
            (C {<cleanup>} {($ Id.VSub_DollarName '$xmlfmtfile')})
          ]
          spids: [347 348 380 -1]
        )
        (case_arm
          pat_list: [{<-pdf>}]
          action: [
            (C {<echo>} {(DQ <'Creating '> ($ Id.VSub_DollarName '$pdffile') <' ...'>)})
            (C {<xsltproc>} {<--nonet>} {<--xinclude>} {<-o>} {($ Id.VSub_DollarName '$fofile')} 
              {($ Id.VSub_DollarName '$xsl_fo')} {($ Id.VSub_DollarName '$xmlfmtfile')}
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (C {<cleanup>} {($ Id.VSub_DollarName '$OUT')} {($ Id.VSub_DollarName '$xmlfmtfile')} 
              {<Id.Lit_Star '*'> <.aux>} {<Id.Lit_Star '*'> <.fo>} {<Id.Lit_Star '*'> <.log>} {<Id.Lit_Star '*'> <.out>}
            )
          ]
          spids: [384 385 464 -1]
        )
        (case_arm
          pat_list: [{<-ps>}]
          action: [
            (C {<echo>} {(DQ <'Creating '> ($ Id.VSub_DollarName '$psfile') <' ...'>)})
            (C {<xsltproc>} {<--nonet>} {<--xinclude>} {<-o>} {($ Id.VSub_DollarName '$fofile')} 
              {($ Id.VSub_DollarName '$xsl_fo')} {($ Id.VSub_DollarName '$xmlfmtfile')}
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.Simple
              words: [{<pdfxmltex>} {($ Id.VSub_DollarName '$fofile')}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$OUT')}
                )
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (C {<pdftops>} {($ Id.VSub_DollarName '$pdffile')} {($ Id.VSub_DollarName '$psfile')})
            (C {<cleanup>} {($ Id.VSub_DollarName '$OUT')} {($ Id.VSub_DollarName '$xmlfmtfile')} 
              {($ Id.VSub_DollarName '$pdffile')} {<Id.Lit_Star '*'> <.aux>} {<Id.Lit_Star '*'> <.fo>} {<Id.Lit_Star '*'> <.log>} 
              {<Id.Lit_Star '*'> <.out>}
            )
          ]
          spids: [468 469 572 -1]
        )
        (case_arm
          pat_list: [{<Id.Lit_Star '*'>}]
          action: [(C {<usage>})]
          spids: [576 577 583 -1]
        )
      ]
    )
  ]
)