[Archivesspace_Users_Group] ead2pdf manual PDF creation?

Steven Majewski sdm7g at virginia.edu
Tue Aug 4 15:03:00 EDT 2015


I’ve forked it at:

https://github.com/sdm7g/ead2pdf <https://github.com/sdm7g/ead2pdf>

and made some changes. It’s working better but still not properly out of the jar file.


Usually, xslt includes are relative based on the base directory of the parent stylesheet,
so this would do it:

diff --git a/lib/as-ead-pdf.xsl b/lib/as-ead-pdf.xsl
index 3954349..ccf041b 100644
--- a/lib/as-ead-pdf.xsl
+++ b/lib/as-ead-pdf.xsl
@@ -21,7 +21,7 @@
     <xsl:output method="xml" encoding="utf-8" indent="yes"/>
     
     <!-- Calls a stylesheet with local functions and lookup lists for languages and subject authorities -->
-    <xsl:include href="./lib/as-helper-functions.xsl"/>  
+    <xsl:include href="as-helper-functions.xsl"/>  
     
     <xsl:strip-space elements="*"/>

However, the XSLT is being passed in as a stream, so it doesn’t have a context for the xslt file path,
and is falling back to the user’s PWD. 

I added this to pass the context in with system_id:

diff --git a/lib/AS_fop.rb b/lib/AS_fop.rb
index 1f97f0e..8b72e3a 100644
--- a/lib/AS_fop.rb
+++ b/lib/AS_fop.rb
@@ -22,6 +22,7 @@ class ASFop
 
   attr_accessor :source
   attr_accessor :xslt
+  attr_accessor :file
 
   def initialize(source, output= nil,  xslt = nil )
    abort("#{source} not found") unless File.exists?(source) 
@@ -30,11 +31,12 @@ class ASFop
    @source = source 
    @xml = IO.read(source)
    @output = output.nil? ? "#{source}.pdf" : output 
+   @file = xslt
    
    if xslt.nil?
-    file =File.join( File.dirname(__FILE__), '../lib' ,'as-ead-pdf.xsl').gsub("\\", "/" )   
-    @xslt = File.read( file, system_id: file )
-   else 
+    @file =File.join( File.dirname(__FILE__) ,'as-ead-pdf.xsl').gsub("\\", "/" )   
+    @xslt = File.read( file, system_id: @file )
+   else
     @xslt = File.read( xslt ) 
    end
   
@@ -42,7 +44,7 @@ class ASFop
 
 
   def to_fo
-    transformer = Saxon.XSLT(@xslt)
+    transformer = Saxon.XSLT(@xslt, system_id: @file )
     transformer.transform(Saxon.XML(@xml)).to_s
   end
 



And it runs correctly if I run calling jruby  on bin/ead2pdf-main.rb. 

However, after packaging up the jar file with warble, I get errors running it out of the jar. 

This gives me an error: 

 java -jar ../sdm7g/ead2pdf/ead2pdf.jar   prod/local-exp/22-MSS12838.xml 22.pdf 
prod/local-exp/22-MSS12838.xml
22.pdf
Error at /xsl:stylesheet/xsl:include[1] in as-ead-pdf.xsl:
  XTSE0165: I/O error reported by XML parser processing
  file:/projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-helper-functions.xsl: /projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-helper-functions.xsl (No such file or directory)


As does this, passing the stylesheet explicitly:

work$ java -jar ../sdm7g/ead2pdf/ead2pdf.jar   prod/local-exp/22-MSS12838.xml 22.pdf 'file:/projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-ead-pdf.xsl' 
prod/local-exp/22-MSS12838.xml
22.pdf
Error at /xsl:stylesheet/xsl:include[1] in as-ead-pdf.xsl:
  XTSE0165: I/O error reported by XML parser processing
  file:/projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-helper-functions.xsl: /projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-helper-functions.xsl (No such file or directory)


But prefixing that URL referencing the jar file with “jar:”  works 
( except that now it’s finding the include, but not finding the .png logo ):

work$ java -jar ../sdm7g/ead2pdf/ead2pdf.jar   prod/local-exp/22-MSS12838.xml 22.pdf 'jar:file:/projects/Archivespace/sdm7g/ead2pdf/ead2pdf.jar!/ead2pdf/lib/as-ead-pdf.xsl' 
prod/local-exp/22-MSS12838.xml
22.pdf
Aug 04, 2015 2:57:05 PM org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI: ./lib/archivesspace.small.png. (See position 74:55)
Aug 04, 2015 2:57:05 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.
Aug 04, 2015 2:57:06 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #2.


Not quite sure how to fix this in the code yet…


— Steve.



> On Aug 4, 2015, at 2:41 PM, Arnold, Hillel <harnold at rockarch.org> wrote:
> 
> Hi Chris,
> I’m still having trouble running this when I’m not in the ead2pdf directory, as Steve points out below.
> 
> Hillel Arnold
> Lead Digital Archivist
> Rockefeller Archive Center
> 
> From: Chris Fitzpatrick <Chris.Fitzpatrick at lyrasis.org <mailto:Chris.Fitzpatrick at lyrasis.org>>
> Reply-To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org <mailto:archivesspace_users_group at lyralists.lyrasis.org>>
> Date: Tuesday, August 4, 2015 at 11:59 AM
> To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org <mailto:archivesspace_users_group at lyralists.lyrasis.org>>
> Subject: Re: [Archivesspace_Users_Group] ead2pdf manual PDF creation?
> 
> 
> 
> Hi,
> 
> Yeah, I just updated the ead2pdf jar, with I think fixes this..
> 
> It's here:
> https://github.com/archivesspace/ead2pdf/releases/tag/0.0.5 <https://github.com/archivesspace/ead2pdf/releases/tag/0.0.5>
>  <https://github.com/archivesspace/ead2pdf/releases/tag/0.0.5>	
> Release 0.0.5 · archivesspace/ead2pdf · GitHub
> ead2pdf - ASpace EAD2PDF
> Read more... <https://github.com/archivesspace/ead2pdf/releases/tag/0.0.5>
> 
> b,chris. 
> 
> Chris Fitzpatrick | Developer, ArchivesSpace
> Skype: chrisfitzpat  | Phone: 918.236.6048
> http://archivesspace.org/ <http://archivesspace.org/>
> 
> 
> From: archivesspace_users_group-bounces at lyralists.lyrasis.org <mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org> <archivesspace_users_group-bounces at lyralists.lyrasis.org <mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org>> on behalf of Steven Majewski <sdm7g at virginia.edu <mailto:sdm7g at virginia.edu>>
> Sent: Tuesday, August 4, 2015 5:51 PM
> To: Archivesspace Users Group
> Subject: Re: [Archivesspace_Users_Group] ead2pdf manual PDF creation?
>  
> 
> I ran the conversion on a random exported EAD file and got the same error. 
> The rest of the message shows it couldn’t find as-helper-functions.xsl 
> 
> work$ java -jar  ../ead2pdf/ead2pdf.jar prod/local-exp/22-MSS12838.xml  22.pdf
> prod/local-exp/22-MSS12838.xml
> 22.pdf
> Error at /xsl:stylesheet/xsl:include[1] 
>   XTSE0165: I/O error reported by XML parser processing
>   file:/projects/Archivespace/work/lib/as-helper-functions.xsl:
>   /projects/Archivespace/work/lib/as-helper-functions.xsl (No such file or directory)
> NoMethodError: undefined method `rewind' for nil:NilClass
> 
> It looks like there’s a path dependency on finding that file:
> 
> ead2pdf$ ack as-helper-functions
> lib/as-ead-pdf.xsl
> 24:    <xsl:include href="./lib/as-helper-functions.xsl"/>  
> 
> lib/AS_fop.rb
> 36:   # @xslt.gsub!('<xsl:include href="as-helper-functions.xsl"/>', "<xsl:include href='#{File.join(File.dirname(__FILE__), '../lib', 'as-helper-functions.xsl')}'/>" ) 
> 
> 
> When I cd into the ead2pdf directory and run the same transform, it runs without error. 
> 
> [ file path is:  ead2pdf/lib/as-helper-functions.xsl ] 
> 
> — Steve. 
> 
> 
> 
>> On Aug 3, 2015, at 11:38 AM, Galligan, Patrick <PGalligan at rockarch.org <mailto:PGalligan at rockarch.org>> wrote:
>> 
>> Hey,
>>  
>> We’re trying to set up a workflow where we automatically generate PDF copies of finding aids from our EAD. Rather than set up two API calls (one to export updated EAD and one to download updated PDF), we wanted to use the ead2pdf.jar to run through and create PDF files.
>>  
>> However, when trying to run it from our dev server, I’m getting the following error:
>>  
>> NoMethodError: undefined method `rewind' for nil:NilClass
>>  
>> Any idea what could be causing that?
>>  
>> Patrick Galligan
>> Rockefeller Archive Center
>> Assistant Digital Archivist
>> 914-366-6386
>>  
>> _______________________________________________
>> Archivesspace_Users_Group mailing list
>> Archivesspace_Users_Group at lyralists.lyrasis.org <mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
>> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group <http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group>
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150804/39363736/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4943 bytes
Desc: not available
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150804/39363736/attachment.bin>


More information about the Archivesspace_Users_Group mailing list