MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Token

Method Token

server/webdav/internal/xml/xml.go:272–325  ·  view source on GitHub ↗

Token returns the next XML token in the input stream. At the end of the input stream, Token returns nil, io.EOF. Slices of bytes in the returned token data refer to the parser's internal buffer and remain valid only until the next call to Token. To acquire a copy of the bytes, call CopyToken or the

()

Source from the content-addressed store, hash-verified

270// If Token encounters an unrecognized name space prefix,
271// it uses the prefix as the Space rather than report an error.
272func (d *Decoder) Token() (t Token, err error) {
273 if d.stk != nil && d.stk.kind == stkEOF {
274 err = io.EOF
275 return
276 }
277 if d.nextToken != nil {
278 t = d.nextToken
279 d.nextToken = nil
280 } else if t, err = d.rawToken(); err != nil {
281 return
282 }
283
284 if !d.Strict {
285 if t1, ok := d.autoClose(t); ok {
286 d.nextToken = t
287 t = t1
288 }
289 }
290 switch t1 := t.(type) {
291 case StartElement:
292 // In XML name spaces, the translations listed in the
293 // attributes apply to the element name and
294 // to the other attribute names, so process
295 // the translations first.
296 for _, a := range t1.Attr {
297 if a.Name.Space == "xmlns" {
298 v, ok := d.ns[a.Name.Local]
299 d.pushNs(a.Name.Local, v, ok)
300 d.ns[a.Name.Local] = a.Value
301 }
302 if a.Name.Space == "" && a.Name.Local == "xmlns" {
303 // Default space for untagged names
304 v, ok := d.ns[""]
305 d.pushNs("", v, ok)
306 d.ns[""] = a.Value
307 }
308 }
309
310 d.translate(&t1.Name, true)
311 for i := range t1.Attr {
312 d.translate(&t1.Attr[i].Name, false)
313 }
314 d.pushElement(t1.Name)
315 t = t1
316
317 case EndElement:
318 d.translate(&t1.Name, true)
319 if !d.popElement(&t1) {
320 return nil, d.err
321 }
322 t = t1
323 }
324 return
325}
326
327const xmlURL = "http://www.w3.org/XML/1998/namespace"
328

Callers 15

parseXMLFunction · 0.95
normalizeMethod · 0.95
TestNestedDirectivesFunction · 0.95
TestTokenFunction · 0.95
TestSyntaxFunction · 0.95
TestUnquotedAttrsFunction · 0.95
TestValuelessAttrsFunction · 0.95
TestSyntaxErrorLineNumFunction · 0.95
TestTrailingTokenFunction · 0.95
TestEntityInsideCDATAFunction · 0.95
TestDisallowedCharactersFunction · 0.95

Calls 6

rawTokenMethod · 0.95
autoCloseMethod · 0.95
pushNsMethod · 0.95
translateMethod · 0.95
pushElementMethod · 0.95
popElementMethod · 0.95

Tested by 14

normalizeMethod · 0.76
TestNestedDirectivesFunction · 0.76
TestTokenFunction · 0.76
TestSyntaxFunction · 0.76
TestUnquotedAttrsFunction · 0.76
TestValuelessAttrsFunction · 0.76
TestSyntaxErrorLineNumFunction · 0.76
TestTrailingTokenFunction · 0.76
TestEntityInsideCDATAFunction · 0.76
TestDisallowedCharactersFunction · 0.76
TestRoundTripFunction · 0.76