<commit_before>package xsd

import (
	"encoding/xml"
)

// NCName represents XML "non-colonized" Names.
// white-space: collapse
type NCName string

// QName represents XML qualified names.
type QName string

// A list of QName
type ListOfQName []QName

// anyURI represents an Internationalized Resource Identifier Reference (IRI).
type anyURI string

// {qualified, unqualified}
type formChoice string

// {extension, restriction}
type reducedDerivationControl string

// {#all} or (possibly empty) subset of {extension, restriction}
type derivationSet string

// {extension, restriction, list, union}
type typeDerivationControl string

// {#all} or (possibly empty) subset of {extension, restriction, list, union}
type fullDerivationSet string

type Schema struct {
	AttributeFormDefault  string `xml:"attributeFormDefault,attr"`
	BlockDefault          string `xml:"blockDefault,attr"`
	DefaultAttributes     string `xml:"defaultAttributes,attr"`
	XpathDefaultNamespace string `xml:"xpathDefaultNamespace,attr"`
	ElementFormDefault    string `xml:"elementFormDefault,attr"`
	FinalDefault          string `xml:"finalDefault,attr"`
	Id                    string `xml:"id,attr"`
	TargetNamespace       string `xml:"targetNamespace,attr"`
	Version               string `xml:"version,attr"`
	//xml:lang = language

	Composition        []interface{}
	DefaultOpenContent *XMLDefaultOpenContent `xml:"defaultOpenContent"`
	Annotation         []Annotation           `xml:"annotation"`
	SchemaTop          []interface{}
}

//  <xs:choice>
//    <xs:element ref="xs:include"/>
//    <xs:element ref="xs:import"/>
//    <xs:element ref="xs:redefine"/>
//    <xs:element ref="xs:override"/>
//    <xs:element ref="xs:annotation"/>
//  </xs:choice>
func unmarshalCompositionGroupChoice(d *xml.Decoder, tok xml.Token) (interface{}, xml.Token, error) {
	var err error
	var r interface{}

	for {
		switch t := tok.(type) {
		case xml.StartElement:
			switch t.Name {

			// <xs:element ref="xs:include"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "include"}:
				x := Include{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:import"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "import"}:
				x := Import{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:redefine"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "redefine"}:
				x := Redefine{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:override"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "override"}:
				x := Override{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:annotation"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "annotation"}:
				x := Annotation{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// unexpected element
			default:
				return nil, tok, nil
			}

			// read next token
			tok, err = d.Token()
			if err != nil {
				return r, tok, err
			}

			return r, tok, nil

		case xml.EndElement:
			return nil, tok, err
		}

		// read next token until xml.StartElement
		tok, err = d.Token()
		if err != nil {
			return r, tok, err
		}

	}

}

func unmarshalSchemaTop(d *xml.Decoder, tok xml.Token) (interface{}, xml.Token, error) {
	var err error
	var r interface{}

	for {
		switch t := tok.(type) {
		case xml.StartElement:
			switch t.Name {

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "simpleType"}:
				x := SimpleType{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "complexType"}:
				x := ComplexType{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "group"}:
				x := Group{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "attributeGroup"}:
				x := AttributeGroup{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "element"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "attribute"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "notation"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// unexpected element
			default:
				return nil, tok, nil
			}

			// read next token<commit_msg>Fixed parsing of topSchema<commit_after>package xsd

import (
	"encoding/xml"
)

// NCName represents XML "non-colonized" Names.
// white-space: collapse
type NCName string

// QName represents XML qualified names.
type QName string

// A list of QName
type ListOfQName []QName

// anyURI represents an Internationalized Resource Identifier Reference (IRI).
type anyURI string

// {qualified, unqualified}
type formChoice string

// {extension, restriction}
type reducedDerivationControl string

// {#all} or (possibly empty) subset of {extension, restriction}
type derivationSet string

// {extension, restriction, list, union}
type typeDerivationControl string

// {#all} or (possibly empty) subset of {extension, restriction, list, union}
type fullDerivationSet string

type Schema struct {
	AttributeFormDefault  string `xml:"attributeFormDefault,attr"`
	BlockDefault          string `xml:"blockDefault,attr"`
	DefaultAttributes     string `xml:"defaultAttributes,attr"`
	XpathDefaultNamespace string `xml:"xpathDefaultNamespace,attr"`
	ElementFormDefault    string `xml:"elementFormDefault,attr"`
	FinalDefault          string `xml:"finalDefault,attr"`
	Id                    string `xml:"id,attr"`
	TargetNamespace       string `xml:"targetNamespace,attr"`
	Version               string `xml:"version,attr"`
	//xml:lang = language

	Composition        []interface{}
	DefaultOpenContent *XMLDefaultOpenContent `xml:"defaultOpenContent"`
	Annotation         []Annotation           `xml:"annotation"`
	SchemaTop          []interface{}
}

//  <xs:choice>
//    <xs:element ref="xs:include"/>
//    <xs:element ref="xs:import"/>
//    <xs:element ref="xs:redefine"/>
//    <xs:element ref="xs:override"/>
//    <xs:element ref="xs:annotation"/>
//  </xs:choice>
func unmarshalCompositionGroupChoice(d *xml.Decoder, tok xml.Token) (interface{}, xml.Token, error) {
	var err error
	var r interface{}

	for {
		switch t := tok.(type) {
		case xml.StartElement:
			switch t.Name {

			// <xs:element ref="xs:include"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "include"}:
				x := Include{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:import"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "import"}:
				x := Import{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:redefine"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "redefine"}:
				x := Redefine{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:override"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "override"}:
				x := Override{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// <xs:element ref="xs:annotation"/>
			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "annotation"}:
				x := Annotation{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// unexpected element
			default:
				return nil, tok, nil
			}

			// read next token
			tok, err = d.Token()
			if err != nil {
				return r, tok, err
			}

			return r, tok, nil

		case xml.EndElement:
			return nil, tok, err
		}

		// read next token until xml.StartElement
		tok, err = d.Token()
		if err != nil {
			return r, tok, err
		}

	}

}

func unmarshalSchemaTop(d *xml.Decoder, tok xml.Token) (interface{}, xml.Token, error) {
	var err error
	var r interface{}

	for {
		switch t := tok.(type) {
		case xml.StartElement:
			switch t.Name {

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "simpleType"}:
				x := SimpleType{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "complexType"}:
				x := ComplexType{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "group"}:
				x := Group{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "attributeGroup"}:
				x := AttributeGroup{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "element"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "attribute"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "notation"}:
				x := Element{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			case xml.Name{Space: "http://www.w3.org/2001/XMLSchema", Local: "annotation"}:
				x := Annotation{}
				if err = d.DecodeElement(&x, &t); err != nil {
					return nil, tok, err
				}
				r = x

			// unexpected element
			default:
				return nil, tok, nil
			}

			// read next token
{'fraction_non_alphanumeric': 0.15769414006669843, 'fraction_numerical': 0.011910433539780848, 'mean_word_length': 2.825072886297376, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 25, 'xml': 71}, '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': '3250492', 'n_tokens_mistral': 4196, 'n_tokens_neox': 3453, 'n_words': 965}