<commit_before># soap-parse.tcl - Copyright (C) 2001 <NAME> <<EMAIL>>
#
# Parse a SOAP reply packet. Returns a list of XPath style element paths
# and the value (if there was a value).
#
# Used by SOAP until I work out how to read the packets using DOM.
#
# @(#)$Id: SOAP-parse.tcl,v 1.2 2001/02/19 00:44:46 pat Exp pat $

package provide SOAP::Parse 1.0

package require xml

# -------------------------------------------------------------------------

namespace eval SOAP::Parse {
    variable elt_path {}
    variable elt_data
}

# -------------------------------------------------------------------------

proc SOAP::Parse::parse { data } {
    variable elt_data

    catch { unset elt_data }
    catch { xml::parser soapyx \
	    -elementstartcommand  SOAP::Parse::elt_start \
	    -elementendcommand    SOAP::Parse::elt_end \
	    -characterdatacommand SOAP::Parse::elt_data } msg
    set parser ::xml::soapyx
    
    $parser parse $data
    
    set r {}
    foreach { key val } [array get elt_data] {
	lappend r $val 
    }

    return $r
}

# -------------------------------------------------------------------------

proc SOAP::Parse::elt_start { name attributes args } {
    variable elt_path
    lappend elt_path $name
}

# -------------------------------------------------------------------------<commit_msg>Modified the parser creation to work with xml1.9 and 2.0.<commit_after># soap-parse.tcl - Copyright (C) 2001 <NAME> <<EMAIL>>
#
# Parse a SOAP reply packet. Returns a list of XPath(ish) style element paths
# and the value (if there was a value).
#
# Used by SOAP until I work out how to read the packets using DOM.
#
# @(#)$Id: SOAP-parse.tcl,v 1.3 2001/03/17 01:23:34 pat Exp pat $

package provide SOAP::Parse 1.0

if { [catch {package require xml 2.0} msg] } {
    if { [catch {package require xml 1.3} msg] } {
	error "required package missing: xml later than version 1.3 needed"
    }
}

# -------------------------------------------------------------------------

namespace eval SOAP::Parse {
    variable elt_path {}
    variable elt_data
    variable parser

    set parser [xml::parser soap \
            -elementstartcommand  SOAP::Parse::elt_start \
            -elementendcommand    SOAP::Parse::elt_end \
            -characterdatacommand SOAP::Parse::elt_data ]
    puts "parser is $parser"
}

# -------------------------------------------------------------------------

proc SOAP::Parse::parse { data } {
    variable elt_data
    variable parser

    catch { unset elt_data }
    $parser parse $data
    
    set r {}
    foreach { key val } [array get elt_data] {
	lappend r $val 
    }

    return $r
}

# -------------------------------------------------------------------------

proc SOAP::Parse::elt_start { name attributes args } {
    variable elt_path
    lappend elt_path $name
}

# -------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.2872890113675508, 'fraction_numerical': 0.018601446779193936, 'mean_word_length': 1.438287153652393, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1402099', 'n_tokens_mistral': 838, 'n_tokens_neox': 792, 'n_words': 257}