Hello,

I am operating with Mustang and want to process Files.

I receive the error 
org.apache.xmpbox.xml.XmpParsingException: Schema is not set in this 
document : http://ns.adobe.com/xap/1.0/sType/ResourceEvent#
        at 
org.apache.xmpbox.xml.DomXmpParser.checkPropertyDefinition(DomXmpParser.java:920)
        at 
org.apache.xmpbox.xml.DomXmpParser.parseLiDescription(DomXmpParser.java:612)
        at 
org.apache.xmpbox.xml.DomXmpParser.parseLiElement(DomXmpParser.java:533)
        at 
org.apache.xmpbox.xml.DomXmpParser.manageArray(DomXmpParser.java:491)
        at 
org.apache.xmpbox.xml.DomXmpParser.createProperty(DomXmpParser.java:356)
        at 
org.apache.xmpbox.xml.DomXmpParser.parseChildrenAsProperties(DomXmpParser.java:322)
        at 
org.apache.xmpbox.xml.DomXmpParser.parseDescriptionRoot(DomXmpParser.java:250)
        at org.apache.xmpbox.xml.DomXmpParser.parse(DomXmpParser.java:201)
        at de.vkb.eos.EosZUGFeRD.Load.main(Load.java:29)

Using PDF Debugger i find metadata
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"; 
               xmlns:iX="http://ns.adobe.com/iX/1.0/"; 
               xmlns:pdf="http://ns.adobe.com/pdf/1.3/"; 
               xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/"; 
               xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
               xmlns:stEvt="
http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"; 
               xmlns:xmp="http://ns.adobe.com/xap/1.0/"; 
               xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/";>
        <xmpMM:History>
                <rdf:Seq>
                        <rdf:li rdf:parseType="Resource">
                                <stEvt:action>created</stEvt:action>
                                <stEvt:parameters>converted to 
PDF/A</stEvt:parameters>
                                <stEvt:softwareAgent>Compart Docponent 
API</stEvt:softwareAgent>
                                <stEvt:when>2025-11-
11T13:16:36+01:00</stEvt:when>
                        </rdf:li>
                </rdf:Seq>
        </xmpMM:History>

This means the namepace IS there. 

Prior to reading the element you parse the description

        if (DomHelper.isParseTypeResource(liElement))
        {
            return parseLiDescription(xmp, descriptor, liElement);
        }
        // will find rdf:Description
        Element liChild = DomHelper.getUniqueElementChild(liElement);
        if (liChild != null)
        {
            nsFinder.push(liChild);
            return parseLiDescription(xmp, descriptor, liChild);
        }

which pushes the element  nsFinder.push(first); and read all Attributes 
NamedNodeMap nnm = description.getAttributes(); of 
<stEvt:action>created</stEvt:action>
But stEvt itself has never been pushed.

Code to reproduce



package de.vkb.eos.EosZUGFeRD;

import java.io.File;
import java.io.IOException;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.common.PDMetadata;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.schema.PDFAIdentificationSchema;
import org.apache.xmpbox.xml.DomXmpParser;
import org.apache.xmpbox.xml.XmpParsingException;

public class Load {
 
        public static void main(String[] args) throws IOException 
        {
 
                PDDocument document = Loader.loadPDF(new File("Empty.pdf"
));
                PDDocumentCatalog catalog = document.getDocumentCatalog();
                PDMetadata metadata = catalog.getMetadata();
                // the PDF version we could get through the document but 
we want the PDF-A version,
                // which is different (and can probably base on different 
PDF versions)
                if (metadata != null) {
                        try {
                                DomXmpParser xmpParser = new 
DomXmpParser();
                                xmpParser.setStrictParsing(false);
                                XMPMetadata xmp = xmpParser.parse(metadata
.createInputStream());

                                PDFAIdentificationSchema pdfaSchema = xmp
.getPDFAIdentificationSchema();
                                if (pdfaSchema != null) {
                                        System.out.println(pdfaSchema
.getPart());
                                }
                        } catch (XmpParsingException e) {
                                e.printStackTrace();
                        } finally {
                                document.close();
                        }
                }
        }
}

Is there a mistake in my operating or in the parsing?

thx

Hans-Juergen
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to