Re: Namespaces are dropped in XMP stream. XML invalid

David Law <[email protected]> Thu, 7 Nov 2024 17:16:01 +0100
Newsgroups gmane.text.xml.fop.user
Message-ID <[email protected]>
--------------VE67Ivic0JPKRkJ052ha1HFG
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Jörn,

its a while ago, in the dim and distant past, but...
...at a customer site, we had some Namespace issues with FOP.
Somewhere, we'd parsed some XML without Namespace awareness.

Something like:

|DocumentBuilderFactory.newInstance()||.setNamespaceAware(true);|

Maybe the products you're using have different defaults for this setting?

T'was just a thought.
Sorry, I can't be more specific than that.

All the best,
Dave

On 07/11/2024 16:48, Jörn Willhöft wrote:
> Well the bug is in Apache FOP (or maybe in Saxon?) Here is a 
> reproducible test procedure:
> I use the FOP binary package from 
> https://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.10-bin.tar.gz&action=download 
> <https://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.10-bin.tar.gz&action=download> 
> and the current Saxon 12.5 HE.
> Create PDF without Saxon:
>    $ fop-2.10/fop/fop -c PDFA3Xmp.xconf -fo PDFXMP.fo -pdf output-ok.pdf
> Create PDF with Saxon:
>   $ export 
> CLASSPATH=SaxonHE12-5J/saxon-he-12.5.jar:SaxonHE12-5J/lib/xmlresolver-5.2.2.jar:SaxonHE12-5J/lib/xmlresolver-5.2.2-data.jar:SaxonHE12-5J/lib/jline-2.14.6.jar 
>
>   $ fop-2.10/fop/fop -c PDFA3Xmp.xconf -fo PDFXMP.fo -pdf 
> output-saxon.pdf
> Result without Saxon:
>   $ pdfinfo -meta output-ok.pdf
> ...
>        <rdf:Description 
> xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" 
> rdf:about="">
>            <pdfaExtension:schemas>
>                <rdf:Bag>
>                    <rdf:li rdf:parseType="Resource">
>                        <pdfaSchema:property 
> xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#">
>                            <rdf:Seq>
>                                <rdf:li rdf:parseType="Resource">
>                                    <pdfaProperty:name 
> xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">split</pdfaProperty:name> 
>
>                                </rdf:li>
>                            </rdf:Seq>
>                        </pdfaSchema:property>
>                    </rdf:li>
>                </rdf:Bag>
>            </pdfaExtension:schemas>
>        </rdf:Description>
> ...
> The result with Saxon is totally messed up:
> $ pdfinfo -meta output-saxon.pdf
> ...
>      <rdf:RDF 
> xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" 
> rdf:about="">
>         <pdfaExtension:schemas>
>            <rdf:Bag>
>               <rdf:li rdf:parseType="Resource">
>                  <pdfaSchema:property>
>                     <rdf:Seq>
>                        <rdf:li rdf:parseType="Resource">
>                           <pdfaProperty:name>split</pdfaProperty:name>
>                        </rdf:li>
>                     </rdf:Seq>
>                  </pdfaSchema:property>
>               </rdf:li>
>            </rdf:Bag>
>         </pdfaExtension:schemas>
>      </rdf:RDF>
> ...
> Not only the namespace attributes xmlns:pdfaSchema and 
> xmlns:pdfaProperty are missing, but also the rdf:Description element 
> is now called rdf:RDF (?!)
> I think it makes sense to create a Jira ticket for this issue. Since I 
> am not a member of the project, shall I sign up and do this?
>
> Cheers
>
>    Jörn Willhöft
>
>> Jörn Willhöft <[email protected]> hat am 07.11.2024 13:34 CET 
>> geschrieben:
>> OK, I am a big step further now. The bug appears in Camel (only) if 
>> Saxon is used anywhere in the Camel Route. I use Saxon to create the 
>> actual FO and additional files. The created FO has the namespaces 
>> where they belong, but somehow Saxon in the classpath seems to 
>> confuse the FOP component internally. Skipping Saxon is not really an 
>> option as I need XSLT 2.0.
>> It is still unclear to me if the problem is in the Camel FOP 
>> component or FOP itself.
>> Cheers
>>
>>     Jörn Willhöft
>>

--------------VE67Ivic0JPKRkJ052ha1HFG
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Jörn,<br>
    <br>
    its a while ago, in the dim and distant past, but...<br>
    ...at a customer site, we had some Namespace issues with FOP.<br>
    Somewhere, we'd parsed some XML without Namespace awareness.<br>
    <br>
    Something like:<br>
    <pre><code>DocumentBuilderFactory.newInstance()</code><code>.setNamespaceAware(true);</code></pre>
    Maybe the products you're using have different defaults for this
    setting?<br>
    <br>
    T'was just a thought.<br>
    Sorry, I can't be more specific than that.<br>
    <br>
    All the best,<br>
    Dave<br>
    <br>
    <div class="moz-cite-prefix">On 07/11/2024 16:48, Jörn Willhöft
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <meta charset="UTF-8">
      <div> Well the bug is in Apache FOP (or maybe in Saxon?) Here is a
        reproducible test procedure: </div>
      <div class="default-style">   </div>
      <div class="default-style"> I use the FOP binary package from <a
href="https://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.10-bin.tar.gz&amp;action=download"
          moz-do-not-send="true">https://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.10-bin.tar.gz&amp;action=download</a>
        and the current Saxon 12.5 HE. </div>
      <div class="default-style">   </div>
      <div class="default-style"> Create PDF without Saxon: </div>
      <div class="default-style">    $ fop-2.10/fop/fop -c
        PDFA3Xmp.xconf -fo PDFXMP.fo -pdf output-ok.pdf </div>
      <div class="default-style">   </div>
      <div class="default-style"> Create PDF with Saxon: </div>
      <div class="default-style">   $ export
CLASSPATH=SaxonHE12-5J/saxon-he-12.5.jar:SaxonHE12-5J/lib/xmlresolver-5.2.2.jar:SaxonHE12-5J/lib/xmlresolver-5.2.2-data.jar:SaxonHE12-5J/lib/jline-2.14.6.jar
        <br>
          $ fop-2.10/fop/fop -c PDFA3Xmp.xconf -fo PDFXMP.fo -pdf
        output-saxon.pdf </div>
      <div class="default-style">   </div>
      <div class="default-style"> Result without Saxon: </div>
      <div class="default-style"> <span style="font-family: monospace;"><span
            style="color: #000000; background-color: #ffffff;"
            data-darkreader-inline-color=""
            data-darkreader-inline-bgcolor="">  $ pdfinfo -meta
            output-ok.pdf</span></span> </div>
      <div class="default-style"> <span style="font-family: monospace;">...<br>
          <span style="color: #000000; background-color: #ffffff;"
            data-darkreader-inline-color=""
            data-darkreader-inline-bgcolor="">
                   &lt;rdf:Description
            xmlns:pdfaExtension=<a class="moz-txt-link-rfc2396E" href="http://www.aiim.org/pdfa/ns/extension/">"http://www.aiim.org/pdfa/ns/extension/"</a>
            rdf:about=""&gt; </span><br>
                     &lt;pdfaExtension:schemas&gt; <br>
                         &lt;rdf:Bag&gt; <br>
                             &lt;rdf:li rdf:parseType="Resource"&gt; <br>
                                 &lt;pdfaSchema:property
          xmlns:pdfaSchema=<a class="moz-txt-link-rfc2396E" href="http://www.aiim.org/pdfa/ns/schema#">"http://www.aiim.org/pdfa/ns/schema#"</a>&gt; <br>
                                     &lt;rdf:Seq&gt; <br>
                                         &lt;rdf:li
          rdf:parseType="Resource"&gt; <br>
                                             &lt;pdfaProperty:name
xmlns:pdfaProperty=<a class="moz-txt-link-rfc2396E" href="http://www.aiim.org/pdfa/ns/property#">"http://www.aiim.org/pdfa/ns/property#"</a>&gt;split&lt;/pdfaProperty:name&gt;
          <br>
                                         &lt;/rdf:li&gt; <br>
                                     &lt;/rdf:Seq&gt; <br>
                                 &lt;/pdfaSchema:property&gt; <br>
                             &lt;/rdf:li&gt; <br>
                         &lt;/rdf:Bag&gt; <br>
                     &lt;/pdfaExtension:schemas&gt; <br>
                 &lt;/rdf:Description&gt;<br>
        </span> </div>
      <div class="default-style"> <span style="font-family: monospace;">...</span>
      </div>
      <div>   </div>
      <div> The result with Saxon is totally messed up: </div>
      <div class="default-style"> <span style="font-family: monospace;"><span
            style="color: #000000; background-color: #ffffff;"
            data-darkreader-inline-color=""
            data-darkreader-inline-bgcolor="">$ pdfinfo -meta
            output-saxon.pdf</span><br>
        </span> </div>
      <div class="default-style"> <span style="font-family: monospace;"><span
            style="color: #000000; background-color: #ffffff;"
            data-darkreader-inline-color=""
            data-darkreader-inline-bgcolor="">...</span></span> </div>
      <div class="default-style"> <span style="font-family: monospace;"><span
            style="color: #000000; background-color: #ffffff;"
            data-darkreader-inline-color=""
            data-darkreader-inline-bgcolor="">      &lt;rdf:RDF
            xmlns:pdfaExtension=<a class="moz-txt-link-rfc2396E" href="http://www.aiim.org/pdfa/ns/extension/">"http://www.aiim.org/pdfa/ns/extension/"</a>
            rdf:about=""&gt; </span><br>
                  &lt;pdfaExtension:schemas&gt; <br>
                     &lt;rdf:Bag&gt; <br>
                        &lt;rdf:li rdf:parseType="Resource"&gt; <br>
                           &lt;pdfaSchema:property&gt; <br>
                              &lt;rdf:Seq&gt; <br>
                                 &lt;rdf:li rdf:parseType="Resource"&gt;
          <br>
                          &lt;pdfaProperty:name&gt;split&lt;/pdfaProperty:name&gt;
          <br>
                                 &lt;/rdf:li&gt; <br>
                              &lt;/rdf:Seq&gt; <br>
                           &lt;/pdfaSchema:property&gt; <br>
                        &lt;/rdf:li&gt; <br>
                     &lt;/rdf:Bag&gt; <br>
                  &lt;/pdfaExtension:schemas&gt; <br>
               &lt;/rdf:RDF&gt;<br>
        </span> </div>
      <div> ... </div>
      <div class="default-style"> Not only the namespace attributes <span
          style="font-family: monospace;">xmlns:pdfaSchema</span> and <span
          style="font-family: monospace;">xmlns:pdfaProperty</span> are
        missing, but also the rdf:Description element is now called
        rdf:RDF (?!) </div>
      <div class="default-style">   </div>
      <div> I think it makes sense to create a Jira ticket for this
        issue. Since I am not a member of the project, shall I sign up
        and do this? </div>
      <div>   </div>
      <div class="io-ox-signature">
        <p>Cheers</p>
        <p>   Jörn Willhöft</p>
      </div>
      <blockquote type="cite">
        <div> Jörn Willhöft <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a> hat am
          07.11.2024 13:34 CET geschrieben: </div>
        <div>   </div>
        <div>   </div>
        <div> OK, I am a big step further now. The bug appears in Camel
          (only) if Saxon is used anywhere in the Camel Route. I use
          Saxon to create the actual FO and additional files. The
          created FO has the namespaces where they belong, but somehow
          Saxon in the classpath seems to confuse the FOP component
          internally. Skipping Saxon is not really an option as I need
          XSLT 2.0. </div>
        <div class="default-style">   </div>
        <div class="default-style"> It is still unclear to me if the
          problem is in the Camel FOP component or FOP itself. </div>
        <div class="default-style">   </div>
        <div class="default-style"> Cheers </div>
        <div class="io-ox-signature">
          <p>    Jörn Willhöft</p>
        </div>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>

--------------VE67Ivic0JPKRkJ052ha1HFG--