You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "openfred2@free.fr" <op...@free.fr> on 2021/10/27 15:20:22 UTC

Cannot declare in XMP RDF additional Schema

Hi,

I use version 2.6 of Apache FOP to produce PDF/A3 from XML through XSLT 
transform (using Saxon HE ) (tried both Java 11 and Java 17).

Everything turns right except that the PDF/A3 I need to create must have 
extra XMP metadata with their own RDF schema.

I successfully integrates the XMP Metadata using <rdf:Description> and 
able to retrieve them but when I try to include just before the RDF 
schema definition, it just failed:

The RDF definition looks like (truncated, removing extra definition of 
fields):


<x:xmpmeta xmlns:x="adobe:ns:meta/">
     <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

         <!-- PDF/A extension schema description for the Factur-X schema.
              It is crucial for PDF/A-3 conformance. Don't touch! -->
         <rdf:Description rdf:about="" 
xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">
             <pdfaExtension:schemas>
                 <rdf:Bag>
                     <rdf:li rdf:parseType="Resource">
                         <pdfaSchema:schema>Factur-X PDFA Extension 
Schema</pdfaSchema:schema>
<pdfaSchema:namespaceURI>urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>fx</pdfaSchema:prefix>
                         <pdfaSchema:property>
<rdf:Seq>
…
</rdf:Seq>
</pdfaSchema:property>
                     </rdf:li>
                 </rdf:Bag>
             </pdfaExtension:schemas>
         </rdf:Description>

Followed by <rdf:Description> with Metadata values this time.

I’ve got the following error:


java.lang.NullPointerException: Cannot invoke 
"org.apache.xmlgraphics.xmp.PropertyAccess.setProperty(org.apache.xmlgraphics.xmp.XMPProperty)" 
because the return value of 
"org.apache.xmlgraphics.xmp.XMPHandler.getCurrentProperties()" is null
at org.apache.xmlgraphics.xmp.XMPHandler.endElement(XMPHandler.java:291)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:190)
at 
net.sf.saxon.event.ContentHandlerProxy.endElement(ContentHandlerProxy.java:400)
at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:148)
at 
net.sf.saxon.event.SequenceNormalizer.endElement(SequenceNormalizer.java:141)
at 
net.sf.saxon.event.ComplexContentOutputter.endElement(ComplexContentOutputter.java:605)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:355)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:752)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:752)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:752)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:752)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:264)
at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:372)
at 
net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(CallTemplate.java:434)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:752)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:142)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at 
net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:389)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:568)
at 
net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:72)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:530)
at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:661)
at 
net.sf.saxon.s9api.Xslt30Transformer.transform(Xslt30Transformer.java:375)

When debugging, I’ve got the following information in the endElement 
method of XMPHandler (through IntelliJ):


- this = {XMPContentHandlerFactory$FOPXMPHandler@4676}
obListener = {XMPMetaElement@4681}
this$0 = {XMPContentHandlerFactory@4682}
meta = {Metadata@4683}
content = {StringBuffer@4684} "Factur-X PDFA Extension Schema"
attributesStack = {Stack@4680}  size = 6
nestingInfoStack = {Stack@4685}  size = 4
contextStack = {Stack@4686}  size = 4
uri = "http://www.aiim.org/pdfa/ns/schema#"

- localName = "schema"

- qName = "pdfaSchema:schema"

- atts = {AttributesImpl@4690}
length = 0
data = null

- this.contextStack = {Stack@4686}  size = 4
0 = {Metadata@4683}
1 = {QName@4695} "pdfaExtension:schemas"
2 = {XMPArray@4696} "XMP array: rdf:Bag, 0"
3 = {QName@4697} "pdfaSchema:schema"

- this.nestingInfoStack = {Stack@4685}  size = 4
0 = "metadata"
1 = "prop:pdfaExtension:schemas"
2 = "Bag"
3 = "prop:pdfaSchema:schema"


It looks like it is at the very first field within RDF schema 
definition, at <pdfaSchema:schema>.


langand resare null just before the “assert this.getCurrentProperties() 
!= null : "no current property";”

The assert goes OK under IntelliJ in debug mode, but then the next line: 
“this.getCurrentProperties().setProperty(prop);” goes wrong with this 
exception (getCurrentProperties()returning null object)

Indeed, in getCurrentProperties(), the returned object is of type 
XMPArray, not PropertyAccess, therefore it returns null.

If I limit the RDF schema definition to only:

         <rdf:Description rdf:about="" 
xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">
             <pdfaExtension:schemas>
                 <rdf:Bag>
                     <rdf:li rdf:parseType="Resource">
                     </rdf:li>
                 </rdf:Bag>
             </pdfaExtension:schemas>
         </rdf:Description>

It’s OK but of course no RDF schema is defined, which is not what I want.

According to PDF/A3, each XMP metadata must have its own schema included 
(self-described).

What is wrong in my way of doing?

Thank you for your help !

Fred