Token on a Node Decoder returns a xml StartElement. It returns a boolean that indicates the a token is the node decoder's end node token; and an error which indicates any error that occurred while retrieving the start element
()
| 26 | // a token is the node decoder's end node token; and an error which indicates any error |
| 27 | // that occurred while retrieving the start element |
| 28 | func (d NodeDecoder) Token() (t xml.StartElement, done bool, err error) { |
| 29 | for { |
| 30 | token, e := d.Decoder.Token() |
| 31 | if e != nil { |
| 32 | return t, done, e |
| 33 | } |
| 34 | |
| 35 | // check if we reach end of the node being decoded |
| 36 | if el, ok := token.(xml.EndElement); ok { |
| 37 | return t, el == d.StartEl.End(), err |
| 38 | } |
| 39 | |
| 40 | if t, ok := token.(xml.StartElement); ok { |
| 41 | return restoreAttrNamespaces(t), false, err |
| 42 | } |
| 43 | |
| 44 | // skip token if it is a comment or preamble or empty space value due to indentation |
| 45 | // or if it's a value and is not expected |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // restoreAttrNamespaces update XML attributes to restore the short namespaces found within |
| 50 | // the raw XML document. |