Class: XmlRelationshipHelper
Defined in: src/helper/xml-relationship-helper.ts:37
Relationship handling for _rels parts (ROADMAP: #55).
Instance methods work on one parsed rels document (initialize /
setXml, then getTargetsByPrefix, getTargetsByType, …). The static
methods are the archive-level helpers that used to live on XmlHelper;
the XmlHelper names remain as deprecated delegates.
Constructors
Constructor
new XmlRelationshipHelper(
xml?,tag?):XmlRelationshipHelper
Defined in: src/helper/xml-relationship-helper.ts:46
Parameters
xml?
Document
tag?
string
Returns
XmlRelationshipHelper
Properties
archive
archive:
IArchive
Defined in: src/helper/xml-relationship-helper.ts:38
file
file:
string
Defined in: src/helper/xml-relationship-helper.ts:39
path
path:
string
Defined in: src/helper/xml-relationship-helper.ts:40
tag
tag:
string
Defined in: src/helper/xml-relationship-helper.ts:41
targets
targets:
Target[] =[]
Defined in: src/helper/xml-relationship-helper.ts:44
xml
xml:
Document
Defined in: src/helper/xml-relationship-helper.ts:42
xmlTargets
xmlTargets:
Element[] =[]
Defined in: src/helper/xml-relationship-helper.ts:43
Methods
assertRelatedContent()
assertRelatedContent(
sourceArchive,check?,assert?):Promise<void>
Defined in: src/helper/xml-relationship-helper.ts:154
This will copy all unhandled related contents into the target archive.
Pptx messages on opening a corrupted file are most likely caused by broken relations and this is going to prevent files from being missed.
Parameters
sourceArchive
IArchive
check?
boolean
assert?
boolean
Returns
Promise<void>
getTargetByRelId()
getTargetByRelId(
findRid):Target
Defined in: src/helper/xml-relationship-helper.ts:113
Parameters
findRid
string
Returns
Target
getTargetsByPrefix()
getTargetsByPrefix(
prefix):Target[]
Defined in: src/helper/xml-relationship-helper.ts:82
Parameters
prefix
string | string[]
Returns
Target[]
getTargetsByType()
getTargetsByType(
type):Target[]
Defined in: src/helper/xml-relationship-helper.ts:102
Parameters
type
string
Returns
Target[]
initialize()
initialize(
archive,file,path,prefix?):Promise<XmlRelationshipHelper|Target[]>
Defined in: src/helper/xml-relationship-helper.ts:54
Parameters
archive
IArchive
file
string
path
string
prefix?
string
Returns
Promise<XmlRelationshipHelper | Target[]>
readTargets()
readTargets():
this
Defined in: src/helper/xml-relationship-helper.ts:123
Returns
this
setXml()
setXml(
xml):XmlRelationshipHelper
Defined in: src/helper/xml-relationship-helper.ts:77
Parameters
xml
Document
Returns
XmlRelationshipHelper
createRelationshipChild()
staticcreateRelationshipChild(archive,targetRelFile,attributes):HelperElement
Defined in: src/helper/xml-relationship-helper.ts:532
HelperElement for XmlHelper.append that adds a <Relationship> to
targetRelFile; the relation is recorded with the archive's content
tracker.
Parameters
archive
IArchive
targetRelFile
string
attributes
RelationshipAttribute
Returns
HelperElement
extendTarget()
staticextendTarget(prefix,subtype,target):Target
Defined in: src/helper/xml-relationship-helper.ts:292
Parameters
prefix
string
subtype
ElementSubtype
target
Target
Returns
Target
getMaxId()
staticgetMaxId(rels,attribute,increment?,minId?):number
Defined in: src/helper/xml-relationship-helper.ts:493
Highest numeric rId among rels (ignoring the -created suffix),
optionally incremented by one and raised to minId.
Parameters
rels
XmlElementCollection | XmlNodeCollection
attribute
string
increment?
boolean
minId?
number
Returns
number
getNextRelId()
staticgetNextRelId(rootArchive,file):Promise<string>
Defined in: src/helper/xml-relationship-helper.ts:474
Next free relationship id of a rels part, suffixed with -created
(rId<max+1>-created). The suffix marks relationships created by
automizer; cleanup relies on it — do not change the format.
Parameters
rootArchive
IArchive
file
string
Returns
Promise<string>
getRelationshipItems()
staticgetRelationshipItems(archive,path,cb,tag?):Promise<Target[]>
Defined in: src/helper/xml-relationship-helper.ts:335
Iterates the <Relationship> elements of a rels part in archive and
lets cb push Targets into the returned list.
Parameters
archive
IArchive
path
string
cb
GetRelationshipsCallback
tag?
string
Returns
Promise<Target[]>
getRelationshipTargetsByPrefix()
staticgetRelationshipTargetsByPrefix(archive,path,prefix):Promise<Target[]>
Defined in: src/helper/xml-relationship-helper.ts:361
All targets of a rels part in archive matching one of the given
prefixes (see parseRelationTarget).
Parameters
archive
IArchive
path
string
prefix
string | string[]
Returns
Promise<Target[]>
getSlideLayoutNumber()
staticgetSlideLayoutNumber(sourceArchive,slideId):Promise<number>
Defined in: src/helper/xml-relationship-helper.ts:549
Parameters
sourceArchive
IArchive
slideId
number
Returns
Promise<number>
getSlideMasterNumber()
staticgetSlideMasterNumber(sourceArchive,slideLayoutId):Promise<number>
Defined in: src/helper/xml-relationship-helper.ts:559
Parameters
sourceArchive
IArchive
slideLayoutId
number
Returns
Promise<number>
getTargetsByRelationshipType()
staticgetTargetsByRelationshipType(archive,path,type):Promise<Target[]>
Defined in: src/helper/xml-relationship-helper.ts:389
All targets of a rels part in archive with the given relationship
Type URI.
Parameters
archive
IArchive
path
string
type
string
Returns
Promise<Target[]>
parseRelationTarget()
staticparseRelationTarget(element,prefix?,matchByPrefix?):Target
Defined in: src/helper/xml-relationship-helper.ts:221
Parses one <Relationship> element into a Target.
With a prefix (e.g. ../charts/chart), the target is matched against
it: the relationship type must end in the prefix's last path segment
(chart; data is mapped to diagramData) and the Target attribute
must start with the prefix. Absolute /ppt/... targets, as written by
pptxgenjs, are matched as if they were relative. A matching target gets
prefix, subtype and updateTargetIndex(); a non-matching one is
returned without prefix — or as undefined if matchByPrefix is set.
number is the trailing number of the target file name (chart12.xml
→ 12, 0 if there is none), filenameBase the part before it.
Parameters
element
Element
prefix?
string
matchByPrefix?
boolean
Returns
Target
resolveElementTarget()
staticresolveElementTarget(archive,relsPath,element,type):Promise<Target>
Defined in: src/helper/xml-relationship-helper.ts:410
Resolves the relationship target a shape element refers to: reads the
element's r:id-style attribute for the given TargetByRelIdMap key
(chart, image, hyperlink, …) and looks it up in relsPath.
Parameters
archive
IArchive
relsPath
string
element
Element
type
string
Returns
Promise<Target>
targetMatchesRelationship()
statictargetMatchesRelationship(relType,subtype,file,prefix):boolean
Defined in: src/helper/xml-relationship-helper.ts:315
true if a relationship of relType pointing at file is the kind of
part addressed by prefix (see parseRelationTarget). Embedded
packages (relType === 'package') always match.
Parameters
relType
string
subtype
string
file
string
prefix
string
Returns
boolean