Skip to content

Commit

Permalink
Merge pull request #17 from gomutex/ppr-seq-fix
Browse files Browse the repository at this point in the history
Paragraph Properties seq fix
  • Loading branch information
gomutex authored Jun 20, 2024
2 parents 1aef81e + 601f910 commit cca2ae7
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 107 deletions.
27 changes: 26 additions & 1 deletion doc/rels.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package doc

import "encoding/xml"
import (
"encoding/xml"
)

// Relationship represents a relationship between elements in an Office Open XML (OOXML) document.
// It includes essential information such as ID, type, target, and target mode.
Expand All @@ -20,3 +22,26 @@ type Relationships struct {
Xmlns string `xml:"xmlns,attr"`
Relationships []*Relationship `xml:"Relationship"`
}

func (r *Relationship) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Name.Local = "Relationship"
start.Attr = []xml.Attr{}

if r.ID != "" {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Id"}, Value: r.ID})
}

if r.Type != "" {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Type"}, Value: r.Type})
}

if r.Target != "" {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "Target"}, Value: r.Target})
}

if r.TargetMode != "" {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "TargetMode"}, Value: r.TargetMode})
}

return e.EncodeElement("", start)
}
Loading

0 comments on commit cca2ae7

Please sign in to comment.