metanorma-bipm 2.5.0 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7934,6 +7934,12 @@
7934
7934
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7935
7935
  <attachment filename="{@name}"/>
7936
7936
  </xsl:for-each>
7937
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
7938
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
7939
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
7940
+ <attachment filename="{$attachment_path}"/>
7941
+ </xsl:for-each>
7942
+ </xsl:if>
7937
7943
  </xsl:variable>
7938
7944
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7939
7945
 
@@ -7946,7 +7952,7 @@
7946
7952
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7947
7953
  </xsl:when>
7948
7954
  <!-- link to the PDF attachment -->
7949
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7955
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
7950
7956
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7951
7957
  </xsl:when>
7952
7958
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8595,7 +8601,16 @@
8595
8601
  </xsl:variable>
8596
8602
  <xsl:variable name="img_src">
8597
8603
  <xsl:choose>
8598
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8604
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8605
+ <xsl:choose>
8606
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8607
+ <xsl:value-of select="@src"/>
8608
+ </xsl:when>
8609
+ <xsl:otherwise>
8610
+ <xsl:value-of select="concat($basepath, @src)"/>
8611
+ </xsl:otherwise>
8612
+ </xsl:choose>
8613
+ </xsl:when>
8599
8614
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8600
8615
  </xsl:choose>
8601
8616
  </xsl:variable>
@@ -8608,7 +8623,7 @@
8608
8623
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8609
8624
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8610
8625
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8611
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8626
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8612
8627
  <xsl:value-of select="$scale"/>
8613
8628
  </xsl:template>
8614
8629
 
@@ -8627,7 +8642,14 @@
8627
8642
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8628
8643
  </xsl:when>
8629
8644
  <xsl:when test="not(starts-with(@src, 'data:'))">
8630
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8645
+ <xsl:choose>
8646
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8647
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8648
+ </xsl:when>
8649
+ <xsl:otherwise>
8650
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8651
+ </xsl:otherwise>
8652
+ </xsl:choose>
8631
8653
  </xsl:when>
8632
8654
  <xsl:otherwise>
8633
8655
  <xsl:value-of select="@src"/>
@@ -8649,7 +8671,14 @@
8649
8671
  </xsl:when>
8650
8672
  <xsl:when test="not(starts-with(@src, 'data:'))">
8651
8673
  <xsl:variable name="src">
8652
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8674
+ <xsl:choose>
8675
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8676
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8677
+ </xsl:when>
8678
+ <xsl:otherwise>
8679
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8680
+ </xsl:otherwise>
8681
+ </xsl:choose>
8653
8682
  </xsl:variable>
8654
8683
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8655
8684
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13397,6 +13426,39 @@
13397
13426
  </pdf:catalog>
13398
13427
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
13399
13428
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
13429
+ <rdf:Description xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#" xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" rdf:about="">
13430
+ <pdfaExtension:schemas>
13431
+ <rdf:Bag>
13432
+ <rdf:li rdf:parseType="Resource">
13433
+ <pdfaSchema:namespaceURI>http://www.aiim.org/pdfua/ns/id/</pdfaSchema:namespaceURI>
13434
+ <pdfaSchema:prefix>pdfuaid</pdfaSchema:prefix>
13435
+ <pdfaSchema:schema>PDF/UA identification schema</pdfaSchema:schema>
13436
+ <pdfaSchema:property>
13437
+ <rdf:Seq>
13438
+ <rdf:li rdf:parseType="Resource">
13439
+ <pdfaProperty:category>internal</pdfaProperty:category>
13440
+ <pdfaProperty:description>PDF/UA version identifier</pdfaProperty:description>
13441
+ <pdfaProperty:name>part</pdfaProperty:name>
13442
+ <pdfaProperty:valueType>Integer</pdfaProperty:valueType>
13443
+ </rdf:li>
13444
+ <rdf:li rdf:parseType="Resource">
13445
+ <pdfaProperty:category>internal</pdfaProperty:category>
13446
+ <pdfaProperty:description>PDF/UA amendment identifier</pdfaProperty:description>
13447
+ <pdfaProperty:name>amd</pdfaProperty:name>
13448
+ <pdfaProperty:valueType>Text</pdfaProperty:valueType>
13449
+ </rdf:li>
13450
+ <rdf:li rdf:parseType="Resource">
13451
+ <pdfaProperty:category>internal</pdfaProperty:category>
13452
+ <pdfaProperty:description>PDF/UA corrigenda identifier</pdfaProperty:description>
13453
+ <pdfaProperty:name>corr</pdfaProperty:name>
13454
+ <pdfaProperty:valueType>Text</pdfaProperty:valueType>
13455
+ </rdf:li>
13456
+ </rdf:Seq>
13457
+ </pdfaSchema:property>
13458
+ </rdf:li>
13459
+ </rdf:Bag>
13460
+ </pdfaExtension:schemas>
13461
+ </rdf:Description>
13400
13462
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
13401
13463
  <!-- Dublin Core properties go here -->
13402
13464
  <dc:title>
@@ -13407,30 +13469,54 @@
13407
13469
 
13408
13470
  </xsl:for-each>
13409
13471
  </xsl:variable>
13410
- <xsl:choose>
13411
- <xsl:when test="normalize-space($title) != ''">
13412
- <xsl:value-of select="$title"/>
13413
- </xsl:when>
13414
- <xsl:otherwise>
13415
- <xsl:text> </xsl:text>
13416
- </xsl:otherwise>
13417
- </xsl:choose>
13472
+ <rdf:Alt>
13473
+ <rdf:li xml:lang="x-default">
13474
+ <xsl:choose>
13475
+ <xsl:when test="normalize-space($title) != ''">
13476
+ <xsl:value-of select="$title"/>
13477
+ </xsl:when>
13478
+ <xsl:otherwise>
13479
+ <xsl:text> </xsl:text>
13480
+ </xsl:otherwise>
13481
+ </xsl:choose>
13482
+ </rdf:li>
13483
+ </rdf:Alt>
13418
13484
  </dc:title>
13419
- <dc:creator>
13485
+ <xsl:variable name="dc_creator">
13420
13486
  <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
13421
13487
 
13422
- <xsl:value-of select="normalize-space(*[local-name() = 'ext']/*[local-name() = 'editorialgroup']/*[local-name() = 'committee'])"/>
13488
+ <rdf:Seq>
13489
+ <rdf:li>
13490
+ <xsl:value-of select="normalize-space(*[local-name() = 'ext']/*[local-name() = 'editorialgroup']/*[local-name() = 'committee'])"/>
13491
+ </rdf:li>
13492
+ </rdf:Seq>
13423
13493
 
13424
13494
  </xsl:for-each>
13425
- </dc:creator>
13426
- <dc:description>
13495
+ </xsl:variable>
13496
+ <xsl:if test="normalize-space($dc_creator) != ''">
13497
+ <dc:creator>
13498
+ <xsl:copy-of select="$dc_creator"/>
13499
+ </dc:creator>
13500
+ </xsl:if>
13501
+
13502
+ <xsl:variable name="dc_description">
13427
13503
  <xsl:variable name="abstract">
13428
13504
 
13429
13505
  <xsl:value-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'title'][@language = $lang and @type = 'title-main']"/>
13430
13506
 
13431
13507
  </xsl:variable>
13432
- <xsl:value-of select="normalize-space($abstract)"/>
13433
- </dc:description>
13508
+ <rdf:Alt>
13509
+ <rdf:li xml:lang="x-default">
13510
+ <xsl:value-of select="normalize-space($abstract)"/>
13511
+ </rdf:li>
13512
+ </rdf:Alt>
13513
+ </xsl:variable>
13514
+ <xsl:if test="normalize-space($dc_description)">
13515
+ <dc:description>
13516
+ <xsl:copy-of select="$dc_description"/>
13517
+ </dc:description>
13518
+ </xsl:if>
13519
+
13434
13520
  <pdf:Keywords>
13435
13521
  <xsl:call-template name="insertKeywords">
13436
13522
  <xsl:with-param name="meta">true</xsl:with-param>
@@ -13445,26 +13531,37 @@
13445
13531
  </x:xmpmeta>
13446
13532
  <!-- add attachments -->
13447
13533
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13448
- <xsl:choose>
13449
- <xsl:when test="normalize-space() != ''">
13450
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13451
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
13452
- </xsl:when>
13453
- <xsl:otherwise>
13454
- <!-- _{filename}_attachments -->
13455
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13456
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13457
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
13458
- </xsl:otherwise>
13459
- </xsl:choose>
13534
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13535
+
13536
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
13537
+ <xsl:attribute name="src">
13538
+ <xsl:choose>
13539
+ <xsl:when test="normalize-space() != ''">
13540
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13541
+ <xsl:value-of select="$src_attachment"/>
13542
+ </xsl:when>
13543
+ <xsl:otherwise>
13544
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13545
+ <xsl:value-of select="$url"/>
13546
+ </xsl:otherwise>
13547
+ </xsl:choose>
13548
+ </xsl:attribute>
13549
+ <xsl:if test="$description != ''">
13550
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13551
+ </xsl:if>
13552
+ </pdf:embedded-file>
13460
13553
  </xsl:for-each>
13461
13554
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13462
13555
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13463
13556
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13464
13557
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13465
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13466
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13467
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
13558
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13559
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13560
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
13561
+ <xsl:if test="$description != ''">
13562
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13563
+ </xsl:if>
13564
+ </pdf:embedded-file>
13468
13565
  </xsl:for-each>
13469
13566
  </xsl:if>
13470
13567
  </xsl:template> <!-- addPDFUAmeta -->
@@ -13842,7 +13939,14 @@
13842
13939
  <xsl:value-of select="$src"/>
13843
13940
  </xsl:when>
13844
13941
  <xsl:otherwise>
13845
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13942
+ <xsl:choose>
13943
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
13944
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
13945
+ </xsl:when>
13946
+ <xsl:otherwise>
13947
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13948
+ </xsl:otherwise>
13949
+ </xsl:choose>
13846
13950
  </xsl:otherwise>
13847
13951
  </xsl:choose>
13848
13952
  </xsl:template>
@@ -21,7 +21,7 @@ module IsoDoc
21
21
  "bipm.#{doctype}.xsl"
22
22
  end
23
23
 
24
- def pdf_options(docxml)
24
+ def pdf_options(docxml, filename)
25
25
  n = configuration.document_namespace
26
26
  q = "//m:bipm-standard/m:bibdata/m:language[@current = 'true']"
27
27
  if docxml.root.name == "metanorma-collection" &&