| 36 | } |
| 37 | |
| 38 | func (c *xmlStartElement) decode(header, data []byte) error { |
| 39 | r := endian.Reader(bytes.NewReader(header), device.LittleEndian) |
| 40 | c.lineNumber = r.Uint32() |
| 41 | c.comment = c.root().decodeString(r) |
| 42 | if err := r.Error(); err != nil { |
| 43 | return err |
| 44 | } |
| 45 | |
| 46 | r = endian.Reader(bytes.NewReader(data), device.LittleEndian) |
| 47 | c.namespace = c.root().decodeString(r) |
| 48 | c.name = c.root().decodeString(r) |
| 49 | attributeStart := r.Uint16() |
| 50 | attributeSize := r.Uint16() |
| 51 | attributeCount := r.Uint16() |
| 52 | if err := r.Error(); err != nil { |
| 53 | return err |
| 54 | } |
| 55 | if attributeSize != xmlAttributeSize { |
| 56 | return fmt.Errorf("Attribute size was not as expected. Got %d, expected %d", |
| 57 | attributeSize, xmlAttributeSize) |
| 58 | } |
| 59 | if r.Uint16() != 0 { |
| 60 | return fmt.Errorf("idIndex != 0 not supported.") |
| 61 | } |
| 62 | if r.Uint16() != 0 { |
| 63 | return fmt.Errorf("classIndex != 0 not supported.") |
| 64 | } |
| 65 | if r.Uint16() != 0 { |
| 66 | return fmt.Errorf("styleIndex != 0 not supported.") |
| 67 | } |
| 68 | |
| 69 | r = endian.Reader(bytes.NewReader(data[attributeStart:]), device.LittleEndian) |
| 70 | c.attributes = make([]xmlAttribute, attributeCount) |
| 71 | for i := range c.attributes { |
| 72 | c.attributes[i].decode(r, c.root()) |
| 73 | } |
| 74 | return r.Error() |
| 75 | } |
| 76 | |
| 77 | func (c *xmlStartElement) updateContext(ctx *xmlContext) { |
| 78 | ctx.indent++ |