Skip to content

cac:ExternalReference can't be used without cbc:EmbeddedDocumentBinaryObject #100

@CasperBE

Description

@CasperBE

cac:AdditionalDocumentReference/cac:Attachment/cac:ExternalReference can be set, but an error is thrown:
XMLWriter::writeAttribute() expects parameter 2 to be string, null given

Proposed change in Attachment.php:

    public function xmlSerialize(Writer $writer): void
    {
        $this->validate();

        if (!empty($this->filePath)) {
            $fileContents = base64_encode(file_get_contents($this->filePath));
            $fileName = basename($this->filePath);
            $mimeType = $this->getFilePathMimeType();

            $writer->write([
               'name'       => Schema::CBC . 'EmbeddedDocumentBinaryObject',
               'value'      => $fileContents,
               'attributes' => [
                   'mimeCode' => $mimeType,
                   'filename' => $fileName,
               ],
           ]);
        } elseif (!empty($this->base64Content)) {
            $fileContents = $this->base64Content;
            $fileName = $this->fileName;
            $mimeType = $this->mimeType;

            $writer->write([
               'name'       => Schema::CBC . 'EmbeddedDocumentBinaryObject',
               'value'      => $fileContents,
               'attributes' => [
                   'mimeCode' => $mimeType,
                   'filename' => $fileName,
               ],
           ]);
        } elseif (!empty($this->externalReference)) {
            $writer->writeElement(
                Schema::CAC . 'ExternalReference',
                [Schema::CBC . 'URI' => $this->externalReference]
            );
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions