Skip to content

Commit

Permalink
Document the DROID XML mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Nov 5, 2023
1 parent c00505b commit ccff91e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/pronom/internal/mappings/droid.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,40 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package mappings contains struct mappings to unmarshal three
// Package mappings contains struct mappings to unmarshall three
// different PRONOM XML formats: the DROID signature file format, the report
// format, and the container format.
package mappings

import "encoding/xml"

// Droid Signature File

// Droid describes the basic top-level structure of a DROID signature
// file.
type Droid struct {
XMLName xml.Name `xml:"FFSignatureFile"`
Version int `xml:",attr"`
Signatures []InternalSignature `xml:"InternalSignatureCollection>InternalSignature"`
FileFormats []FileFormat `xml:"FileFormatCollection>FileFormat"`
}

// InternalSignature describes the structure of the InternalSignature
// section of a DROID signature file.
type InternalSignature struct {
ID int `xml:"ID,attr"`
ByteSequences []ByteSeq `xml:"ByteSequence"`
}

// ByteSeq describes the structure of the ByteSequence sections of a
// DROID signature file.
type ByteSeq struct {
Reference string `xml:"Reference,attr"`
SubSequences []SubSequence `xml:"SubSequence"`
}

// SubSequence describes the structure of the SubSequence sections of a
// DROID signature file.
type SubSequence struct {
Position int `xml:",attr"`
SubSeqMinOffset string `xml:",attr"` // and empty int values are unmarshalled to 0
Expand All @@ -45,13 +55,17 @@ type SubSequence struct {
RightFragments []Fragment `xml:"RightFragment"`
}

// Fragment describes the structure of the fragment sections of a DROID
// signature file.
type Fragment struct {
Value string `xml:",chardata"`
MinOffset string `xml:",attr"`
MaxOffset string `xml:",attr"`
Position int `xml:",attr"`
}

// FileFormat describes the structure of the FileFormat section of a
// DROID signature file.
type FileFormat struct {
XMLName xml.Name `xml:"FileFormat"`
ID int `xml:"ID,attr"`
Expand Down

0 comments on commit ccff91e

Please sign in to comment.