Skip to content

Commit

Permalink
Avoid a max call stack size for documents with many relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
wvbe committed Mar 6, 2024
1 parent a8a46c9 commit 80499fe
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/files/RelationshipsXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,28 @@ export class RelationshipsXml extends XmlFileWithContentTypes {
return create(
`
element ${QNS.relationshipsDocument}Relationships {
for $relationship in array:flatten($relationships)
return element ${QNS.relationshipsDocument}Relationship {
attribute Id { $relationship('id') },
attribute Type { $relationship('type') },
attribute Target { $relationship('target') },
if ($relationship('isExternal')) then attribute TargetMode {
"External"
} else ()
}
$relationships
}
`,
{
relationships: this.meta.map((meta) => ({
...meta,
target: meta.isExternal
? meta.target
: path.relative(path.dirname(path.dirname(this.location)), meta.target),
})),
relationships: this.meta.map((meta) =>
create(
`element ${QNS.relationshipsDocument}Relationship {
attribute Id { $id },
attribute Type { $type },
attribute Target { $target },
if ($isExternal) then attribute TargetMode {
"External"
} else ()
}`,
{
...meta,
target: meta.isExternal
? meta.target
: path.relative(path.dirname(path.dirname(this.location)), meta.target),
},
),
),
},
true,
);
Expand Down

0 comments on commit 80499fe

Please sign in to comment.