metanorma-ogc 2.6.0 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6897,6 +6897,12 @@
6897
6897
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
6898
6898
  <attachment filename="{@name}"/>
6899
6899
  </xsl:for-each>
6900
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
6901
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
6902
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
6903
+ <attachment filename="{$attachment_path}"/>
6904
+ </xsl:for-each>
6905
+ </xsl:if>
6900
6906
  </xsl:variable>
6901
6907
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
6902
6908
 
@@ -6909,7 +6915,7 @@
6909
6915
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6910
6916
  </xsl:when>
6911
6917
  <!-- link to the PDF attachment -->
6912
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
6918
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
6913
6919
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
6914
6920
  </xsl:when>
6915
6921
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -7558,7 +7564,16 @@
7558
7564
  </xsl:variable>
7559
7565
  <xsl:variable name="img_src">
7560
7566
  <xsl:choose>
7561
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
7567
+ <xsl:when test="not(starts-with(@src, 'data:'))">
7568
+ <xsl:choose>
7569
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
7570
+ <xsl:value-of select="@src"/>
7571
+ </xsl:when>
7572
+ <xsl:otherwise>
7573
+ <xsl:value-of select="concat($basepath, @src)"/>
7574
+ </xsl:otherwise>
7575
+ </xsl:choose>
7576
+ </xsl:when>
7562
7577
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
7563
7578
  </xsl:choose>
7564
7579
  </xsl:variable>
@@ -7571,7 +7586,7 @@
7571
7586
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
7572
7587
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
7573
7588
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
7574
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7589
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7575
7590
  <xsl:value-of select="$scale"/>
7576
7591
  </xsl:template>
7577
7592
 
@@ -7590,7 +7605,14 @@
7590
7605
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
7591
7606
  </xsl:when>
7592
7607
  <xsl:when test="not(starts-with(@src, 'data:'))">
7593
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7608
+ <xsl:choose>
7609
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
7610
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
7611
+ </xsl:when>
7612
+ <xsl:otherwise>
7613
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7614
+ </xsl:otherwise>
7615
+ </xsl:choose>
7594
7616
  </xsl:when>
7595
7617
  <xsl:otherwise>
7596
7618
  <xsl:value-of select="@src"/>
@@ -7612,7 +7634,14 @@
7612
7634
  </xsl:when>
7613
7635
  <xsl:when test="not(starts-with(@src, 'data:'))">
7614
7636
  <xsl:variable name="src">
7615
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7637
+ <xsl:choose>
7638
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
7639
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
7640
+ </xsl:when>
7641
+ <xsl:otherwise>
7642
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7643
+ </xsl:otherwise>
7644
+ </xsl:choose>
7616
7645
  </xsl:variable>
7617
7646
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
7618
7647
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -12377,6 +12406,39 @@
12377
12406
  </pdf:catalog>
12378
12407
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
12379
12408
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
12409
+ <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="">
12410
+ <pdfaExtension:schemas>
12411
+ <rdf:Bag>
12412
+ <rdf:li rdf:parseType="Resource">
12413
+ <pdfaSchema:namespaceURI>http://www.aiim.org/pdfua/ns/id/</pdfaSchema:namespaceURI>
12414
+ <pdfaSchema:prefix>pdfuaid</pdfaSchema:prefix>
12415
+ <pdfaSchema:schema>PDF/UA identification schema</pdfaSchema:schema>
12416
+ <pdfaSchema:property>
12417
+ <rdf:Seq>
12418
+ <rdf:li rdf:parseType="Resource">
12419
+ <pdfaProperty:category>internal</pdfaProperty:category>
12420
+ <pdfaProperty:description>PDF/UA version identifier</pdfaProperty:description>
12421
+ <pdfaProperty:name>part</pdfaProperty:name>
12422
+ <pdfaProperty:valueType>Integer</pdfaProperty:valueType>
12423
+ </rdf:li>
12424
+ <rdf:li rdf:parseType="Resource">
12425
+ <pdfaProperty:category>internal</pdfaProperty:category>
12426
+ <pdfaProperty:description>PDF/UA amendment identifier</pdfaProperty:description>
12427
+ <pdfaProperty:name>amd</pdfaProperty:name>
12428
+ <pdfaProperty:valueType>Text</pdfaProperty:valueType>
12429
+ </rdf:li>
12430
+ <rdf:li rdf:parseType="Resource">
12431
+ <pdfaProperty:category>internal</pdfaProperty:category>
12432
+ <pdfaProperty:description>PDF/UA corrigenda identifier</pdfaProperty:description>
12433
+ <pdfaProperty:name>corr</pdfaProperty:name>
12434
+ <pdfaProperty:valueType>Text</pdfaProperty:valueType>
12435
+ </rdf:li>
12436
+ </rdf:Seq>
12437
+ </pdfaSchema:property>
12438
+ </rdf:li>
12439
+ </rdf:Bag>
12440
+ </pdfaExtension:schemas>
12441
+ </rdf:Description>
12380
12442
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
12381
12443
  <!-- Dublin Core properties go here -->
12382
12444
  <dc:title>
@@ -12387,33 +12449,57 @@
12387
12449
 
12388
12450
  </xsl:for-each>
12389
12451
  </xsl:variable>
12390
- <xsl:choose>
12391
- <xsl:when test="normalize-space($title) != ''">
12392
- <xsl:value-of select="$title"/>
12393
- </xsl:when>
12394
- <xsl:otherwise>
12395
- <xsl:text> </xsl:text>
12396
- </xsl:otherwise>
12397
- </xsl:choose>
12452
+ <rdf:Alt>
12453
+ <rdf:li xml:lang="x-default">
12454
+ <xsl:choose>
12455
+ <xsl:when test="normalize-space($title) != ''">
12456
+ <xsl:value-of select="$title"/>
12457
+ </xsl:when>
12458
+ <xsl:otherwise>
12459
+ <xsl:text> </xsl:text>
12460
+ </xsl:otherwise>
12461
+ </xsl:choose>
12462
+ </rdf:li>
12463
+ </rdf:Alt>
12398
12464
  </dc:title>
12399
- <dc:creator>
12465
+ <xsl:variable name="dc_creator">
12400
12466
  <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
12401
12467
 
12402
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']">
12403
- <xsl:value-of select="*[local-name() = 'organization']/*[local-name() = 'name']"/>
12404
- <xsl:if test="position() != last()">; </xsl:if>
12405
- </xsl:for-each>
12468
+ <rdf:Seq>
12469
+ <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']">
12470
+ <rdf:li>
12471
+ <xsl:value-of select="*[local-name() = 'organization']/*[local-name() = 'name']"/>
12472
+ </rdf:li>
12473
+ <!-- <xsl:if test="position() != last()">; </xsl:if> -->
12474
+ </xsl:for-each>
12475
+ </rdf:Seq>
12406
12476
 
12407
12477
  </xsl:for-each>
12408
- </dc:creator>
12409
- <dc:description>
12478
+ </xsl:variable>
12479
+ <xsl:if test="normalize-space($dc_creator) != ''">
12480
+ <dc:creator>
12481
+ <xsl:copy-of select="$dc_creator"/>
12482
+ </dc:creator>
12483
+ </xsl:if>
12484
+
12485
+ <xsl:variable name="dc_description">
12410
12486
  <xsl:variable name="abstract">
12411
12487
 
12412
12488
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*[local-name() = 'abstract']//text()[not(ancestor::*[local-name() = 'title'])]"/>
12413
12489
 
12414
12490
  </xsl:variable>
12415
- <xsl:value-of select="normalize-space($abstract)"/>
12416
- </dc:description>
12491
+ <rdf:Alt>
12492
+ <rdf:li xml:lang="x-default">
12493
+ <xsl:value-of select="normalize-space($abstract)"/>
12494
+ </rdf:li>
12495
+ </rdf:Alt>
12496
+ </xsl:variable>
12497
+ <xsl:if test="normalize-space($dc_description)">
12498
+ <dc:description>
12499
+ <xsl:copy-of select="$dc_description"/>
12500
+ </dc:description>
12501
+ </xsl:if>
12502
+
12417
12503
  <pdf:Keywords>
12418
12504
  <xsl:call-template name="insertKeywords">
12419
12505
  <xsl:with-param name="meta">true</xsl:with-param>
@@ -12428,26 +12514,37 @@
12428
12514
  </x:xmpmeta>
12429
12515
  <!-- add attachments -->
12430
12516
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
12431
- <xsl:choose>
12432
- <xsl:when test="normalize-space() != ''">
12433
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
12434
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
12435
- </xsl:when>
12436
- <xsl:otherwise>
12437
- <!-- _{filename}_attachments -->
12438
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
12439
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
12440
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
12441
- </xsl:otherwise>
12442
- </xsl:choose>
12517
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
12518
+
12519
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
12520
+ <xsl:attribute name="src">
12521
+ <xsl:choose>
12522
+ <xsl:when test="normalize-space() != ''">
12523
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
12524
+ <xsl:value-of select="$src_attachment"/>
12525
+ </xsl:when>
12526
+ <xsl:otherwise>
12527
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
12528
+ <xsl:value-of select="$url"/>
12529
+ </xsl:otherwise>
12530
+ </xsl:choose>
12531
+ </xsl:attribute>
12532
+ <xsl:if test="$description != ''">
12533
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
12534
+ </xsl:if>
12535
+ </pdf:embedded-file>
12443
12536
  </xsl:for-each>
12444
12537
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
12445
12538
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
12446
12539
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
12447
12540
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
12448
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
12449
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
12450
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
12541
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
12542
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
12543
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
12544
+ <xsl:if test="$description != ''">
12545
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
12546
+ </xsl:if>
12547
+ </pdf:embedded-file>
12451
12548
  </xsl:for-each>
12452
12549
  </xsl:if>
12453
12550
  </xsl:template> <!-- addPDFUAmeta -->
@@ -12825,7 +12922,14 @@
12825
12922
  <xsl:value-of select="$src"/>
12826
12923
  </xsl:when>
12827
12924
  <xsl:otherwise>
12828
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12925
+ <xsl:choose>
12926
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
12927
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
12928
+ </xsl:when>
12929
+ <xsl:otherwise>
12930
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12931
+ </xsl:otherwise>
12932
+ </xsl:choose>
12829
12933
  </xsl:otherwise>
12830
12934
  </xsl:choose>
12831
12935
  </xsl:template>
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  end
65
65
 
66
66
  def header_strip(hdr)
67
- hdr = hdr.to_s.gsub(/<\/?p[^>]*>/, "")
67
+ hdr = hdr.to_s.gsub(/<\/?p[^<>]*>/, "")
68
68
  super
69
69
  end
70
70