3 // NoneRequired returns a deep copy of the receiver with any required
4 // attributes translated to optional.
5 func (b *Block) NoneRequired() *Block {
8 if b.Attributes != nil {
9 ret.Attributes = make(map[string]*Attribute, len(b.Attributes))
11 for name, attrS := range b.Attributes {
12 ret.Attributes[name] = attrS.forceOptional()
15 if b.BlockTypes != nil {
16 ret.BlockTypes = make(map[string]*NestedBlock, len(b.BlockTypes))
18 for name, blockS := range b.BlockTypes {
19 ret.BlockTypes[name] = blockS.noneRequired()
25 func (b *NestedBlock) noneRequired() *NestedBlock {
27 ret.Block = *(ret.Block.NoneRequired())
33 func (a *Attribute) forceOptional() *Attribute {