[latex3-commits] [latex3/pdfresources] schema-commands: support addition of external schemas like zugferd (75ebd5a)

github at latex-project.org github at latex-project.org
Fri Sep 13 11:54:26 CEST 2024


Repository : https://github.com/latex3/pdfresources
On branch  : schema-commands
Link       : https://github.com/latex3/pdfresources/commit/75ebd5ab48e4905dfc03e28c9dda109069b96bb2

>---------------------------------------------------------------

commit 75ebd5ab48e4905dfc03e28c9dda109069b96bb2
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Sep 13 11:54:26 2024 +0200

    support addition of external schemas like zugferd


>---------------------------------------------------------------

75ebd5ab48e4905dfc03e28c9dda109069b96bb2
 CHANGELOG.md  |   2 +
 l3pdfmeta.dtx | 130 +++++++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 95 insertions(+), 37 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f26320..1f4ea58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Added
  - ltdocinit.dtx: add \LogDocumentProperties
+ - l3pdfmeta: Support additions of external schemas like ZUGferd with
+   \pdfmeta_xmp_schema_new:nnn \pdfmeta_xmp_property_new:nnnnn
 
 ### Fixed 
  - colorspace-patches-tmp-ltx.sty: fixes hook use, issue #78
diff --git a/l3pdfmeta.dtx b/l3pdfmeta.dtx
index 1126a42..4bde7c2 100644
--- a/l3pdfmeta.dtx
+++ b/l3pdfmeta.dtx
@@ -594,7 +594,8 @@
 % \begin{syntax}
 % \cs{pdfmeta_xmp_xmlns_new:nn}\Arg{prefix}\Arg{uri}
 % \end{syntax}
-% With this command a xmlns name space can be added.
+% With this command a xmlns name space can be added. The \meta{uri}
+% argument is expanded, a hash can be input with |\c_hash_str|.
 % \end{function}
 %
 % With the two following commands PDF declarations can be added to the XMP metadata
@@ -624,6 +625,38 @@
 % If  \cs{pdfmeta_xmp_add_declaration:nnnnn} is used twice with the same \meta{uri}
 % argument the |claimData| are concatenated. There is no check if the |claimData| are identical. 
 % \end{function}
+% 
+% The following two commands can be used to extend the schema declarations in
+% the XMP metadata. This is for example needed to implement a standard like ZUGferd/Factur X
+% for invoices. A schema declaration should be added only once but as this task
+% is probably not needed frequently only light guards are there to avoid duplicated entries.
+%  
+% \begin{function}{\pdfmeta_xmp_schema_new:nnn}
+% \begin{syntax}
+% \cs{pdfmeta_xmp_schema_new:nnn}\Arg{text}\Arg{prefix}\Arg{uri}
+% \end{syntax}
+% \meta{text} is some string describing the schema, e.g. |PDF/A~Identification~Schema|,
+% \meta{prefix} is the unique prefix used by the schema. This prefix
+% must be declared first with |\pdfmeta_xmp_xmlns_new:nn|. If a schema with this prefix
+% has already been declared, it will currently be ignored with a warning. 
+% The \meta{uri} is expanded, so a
+% hash can for example be given as |\c_hash_str|. 
+% \end{function}
+
+% \begin{function}{\pdfmeta_xmp_property_new:nnnnn}
+% \begin{syntax}
+% \cs{pdfmeta_xmp_property_new:nnnnn}\Arg{schema prefix}\Arg{name}\Arg{type}\Arg{category}\Arg{description}
+% \end{syntax}
+% If the new property already exists in the schema
+% (as identified by the combination of \meta{schema prefix}
+% and \meta{name} the property is silently ignore. 
+% \meta{schema prefix} is the prefix declared with the previous command.
+% schema, e.g. |PDF/A~Identification~Schema|,
+% \meta{name} is a short string that identifies the property, e.g. |xmpMM| or |year|. It must be
+% unique in the properties of a schema. \meta{type} is e.g. |URI| or |Integer| or |Text|, 
+% \meta{category} is e.g. |internal| or |external|, \meta{description} is a free description string. 
+% \end{function}
+% 
 % \end{documentation}
 %
 % \begin{implementation}
@@ -1438,7 +1471,7 @@
 %    \end{macrocode}
 % \subsection{Messages}
 %    \begin{macrocode}
-\msg_new:nnn{pdfmeta}{namespace-defined}{The~xmlns~namespace~`#1`~is~already~declared}
+\msg_new:nnn{pdfmeta}{namespace-defined}{The~#1~`#2`~is~already~declared}
 \msg_new:nnn{pdfmeta}{colorprofile-undefined}{The~colorprofile~`#1`~is~unknown}
 %    \end{macrocode}
 % \subsection{Some helper commands}
@@ -1970,7 +2003,7 @@
 \prop_new:N \g_@@_xmp_xmlns_prop
 %    \end{macrocode}
 % \end{variable}
-% \begin{macro}{\@@_xmp_xmlns_new:nn,\@@_xmp_xmlns_new:ne}
+% \begin{macro}{\@@_xmp_xmlns_new:nn}
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_xmp_xmlns_new:nn #1 #2
   {
@@ -1980,7 +2013,6 @@
         \@@_xmp_indent:n{4} xmlns:\exp_not:n{#1="#2"}
       }
   }
-\cs_generate_variant:Nn \@@_xmp_xmlns_new:nn {ne}
 %    \end{macrocode}
 % \end{macro}
 % Now we fill the data. The list is more or less the same as in hyperxmp
@@ -1991,7 +2023,7 @@
 \@@_xmp_xmlns_new:nn {photoshop}{http://ns.adobe.com/photoshop/1.0/}
 \@@_xmp_xmlns_new:nn {xmp}      {http://ns.adobe.com/xap/1.0/}
 \@@_xmp_xmlns_new:nn {xmpMM}    {http://ns.adobe.com/xap/1.0/mm/}
-\@@_xmp_xmlns_new:ne {stEvt}
+\@@_xmp_xmlns_new:nn {stEvt}
   {http://ns.adobe.com/xap/1.0/sType/ResourceEvent\c_hash_str}
 \@@_xmp_xmlns_new:nn {pdfaid}   {http://www.aiim.org/pdfa/ns/id/}
 \@@_xmp_xmlns_new:nn {pdfuaid}  {http://www.aiim.org/pdfua/ns/id/}
@@ -2000,13 +2032,13 @@
 \@@_xmp_xmlns_new:nn {prism}    {http://prismstandard.org/namespaces/basic/3.0/}
 %\@@_xmp_xmlns_new:nn {jav}      {http://www.niso.org/schemas/jav/1.0/}
 %\@@_xmp_xmlns_new:nn {xmpTPg}   {http://ns.adobe.com/xap/1.0/t/pg/}
-\@@_xmp_xmlns_new:ne {stFnt}    {http://ns.adobe.com/xap/1.0/sType/Font\c_hash_str}
+\@@_xmp_xmlns_new:nn {stFnt}    {http://ns.adobe.com/xap/1.0/sType/Font\c_hash_str}
 \@@_xmp_xmlns_new:nn {Iptc4xmpCore}{http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/}
 \@@_xmp_xmlns_new:nn {pdfaExtension}{http://www.aiim.org/pdfa/ns/extension/}
-\@@_xmp_xmlns_new:ne {pdfaSchema}{http://www.aiim.org/pdfa/ns/schema\c_hash_str}
-\@@_xmp_xmlns_new:ne {pdfaProperty}{http://www.aiim.org/pdfa/ns/property\c_hash_str}
-\@@_xmp_xmlns_new:ne {pdfaType} {http://www.aiim.org/pdfa/ns/type\c_hash_str}
-\@@_xmp_xmlns_new:ne {pdfaField}{http://www.aiim.org/pdfa/ns/field\c_hash_str}
+\@@_xmp_xmlns_new:nn {pdfaSchema}{http://www.aiim.org/pdfa/ns/schema\c_hash_str}
+\@@_xmp_xmlns_new:nn {pdfaProperty}{http://www.aiim.org/pdfa/ns/property\c_hash_str}
+\@@_xmp_xmlns_new:nn {pdfaType} {http://www.aiim.org/pdfa/ns/type\c_hash_str}
+\@@_xmp_xmlns_new:nn {pdfaField}{http://www.aiim.org/pdfa/ns/field\c_hash_str}
 %    \end{macrocode}
 
 % \subsection{Building the chunks: Extensions}
@@ -2033,41 +2065,54 @@
 \cs_new_protected:Npn \@@_xmp_schema_new:nnn #1 #2 #3
   %#1 name #2 prefix, #3 text
   {
-    \seq_put_right:Nn \l_@@_xmp_schema_seq { #2 }
-    \tl_new:c { g_@@_xmp_schema_#2_tl }
-    \tl_new:c { g_@@_xmp_schema_#2_properties_tl }
-    \tl_gput_right:cn { g_@@_xmp_schema_#2_tl }
+    \tl_if_exist:cTF { g_@@_xmp_schema_#2_tl }
       {
-        \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
-         \@@_xmp_add_packet_line:nnn {pdfaSchema}{schema}{#1}
-         \@@_xmp_add_packet_line:nnn {pdfaSchema}{prefix}{#2}
-         \@@_xmp_add_packet_line:nnn {pdfaSchema}{namespaceURI}{#3}
-         \@@_xmp_add_packet_open:nn {pdfaSchema}{property}
-          \@@_xmp_add_packet_open:nn{rdf}{Seq}
-              \tl_use:c { g_@@_xmp_schema_#2_properties_tl }
-          \@@_xmp_add_packet_close:nn{rdf}{Seq}
-         \@@_xmp_add_packet_close:nn {pdfaSchema}{property}
-        \cs_if_exist_use:c {@@_xmp_schema_#2_additions:}
-        \@@_xmp_add_packet_close:nn{rdf}{li}
+       \msg_warning:nnnn{pdfmeta}{namespace-defined}{schema}{#2}
+      }
+      {
+        \seq_put_right:Nn \l_@@_xmp_schema_seq { #2 }
+        \tl_new:c { g_@@_xmp_schema_#2_tl }
+        \tl_new:c { g_@@_xmp_schema_#2_properties_tl }
+        \tl_gput_right:cn { g_@@_xmp_schema_#2_tl }
+          {
+            \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
+             \@@_xmp_add_packet_line:nnn {pdfaSchema}{schema}{#1}
+             \@@_xmp_add_packet_line:nnn {pdfaSchema}{prefix}{#2}
+             \@@_xmp_add_packet_line:nnn {pdfaSchema}{namespaceURI}{#3}
+             \@@_xmp_add_packet_open:nn {pdfaSchema}{property}
+              \@@_xmp_add_packet_open:nn{rdf}{Seq}
+                  \tl_use:c { g_@@_xmp_schema_#2_properties_tl }
+              \@@_xmp_add_packet_close:nn{rdf}{Seq}
+             \@@_xmp_add_packet_close:nn {pdfaSchema}{property}
+            \cs_if_exist_use:c {@@_xmp_schema_#2_additions:}
+            \@@_xmp_add_packet_close:nn{rdf}{li}
+          }
       } 
   }
 %    \end{macrocode}
 % \end{macro}
-
-% \begin{macro}{\@@_xmp_property_new:nnn}
+% 
+%
+%
+% \begin{macro}{\@@_xmp_property_new:nnnnn}
 %  This adds a property to a schema.
 %    \begin{macrocode}
+\prop_new:N\g_@@_xmp_schema_property_prop
 \cs_new_protected:Npn \@@_xmp_property_new:nnnnn #1 #2 #3 #4 #5 %
     %#1 schema #2 name, #3 type, #4 category #5 description
   {
-    \tl_gput_right:cn { g_@@_xmp_schema_#1_properties_tl }
-      {
-        \@@_xmp_add_packet_open:nn {rdf}{li~rdf:parseType="Resource"}
-          \@@_xmp_add_packet_line:nnn {pdfaProperty}{name}{#2}
-          \@@_xmp_add_packet_line:nnn {pdfaProperty}{valueType}{#3}
-          \@@_xmp_add_packet_line:nnn {pdfaProperty}{category}{#4}
-          \@@_xmp_add_packet_line:nnn {pdfaProperty}{description}{#5}
-        \@@_xmp_add_packet_close:nn{rdf}{li}
+    \prop_get:NeNF \g_@@_xmp_schema_property_prop {#1:#2}\l_@@_tmpa_tl
+     {
+       \prop_gput:Nee \g_@@_xmp_schema_property_prop {#1:#2}{#3}
+       \tl_gput_right:cn { g_@@_xmp_schema_#1_properties_tl }
+         {
+           \@@_xmp_add_packet_open:nn {rdf}{li~rdf:parseType="Resource"}
+             \@@_xmp_add_packet_line:nnn {pdfaProperty}{name}{#2}
+             \@@_xmp_add_packet_line:nnn {pdfaProperty}{valueType}{#3}
+             \@@_xmp_add_packet_line:nnn {pdfaProperty}{category}{#4}
+             \@@_xmp_add_packet_line:nnn {pdfaProperty}{description}{#5}
+           \@@_xmp_add_packet_close:nn{rdf}{li}
+        }
      }
   }
 %    \end{macrocode}
@@ -2352,7 +2397,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_xmp_schema_enable_pdfd:
  {
-  \@@_xmp_xmlns_new:ne {pdfd}{http://pdfa.org/declarations/} 
+  \@@_xmp_xmlns_new:nn {pdfd}{http://pdfa.org/declarations/} 
   \@@_xmp_schema_new:nnn
     {PDF~Declarations~Schema}
     {pdfd}
@@ -2972,11 +3017,22 @@
 \cs_new_protected:Npn \pdfmeta_xmp_xmlns_new:nn #1 #2
   {
     \prop_if_in:NnTF \g_@@_xmp_xmlns_prop {#1}
-      {\msg_warning:nnn{pdfmeta}{namespace-defined}{#1}}
+      {\msg_warning:nnnn{pdfmeta}{namespace-defined}{xmlns~namespace}{#1}}
       {\@@_xmp_xmlns_new:nn {#1}{#2}}
   }
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\pdfmeta_xmp_schema_new:nnn}
+%    \begin{macrocode}
+\cs_set_eq:NN \pdfmeta_xmp_schema_new:nnn \@@_xmp_schema_new:nnn
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\pdfmeta_xmp_property_new:nnnnn}
+%    \begin{macrocode}
+\cs_set_eq:NN \pdfmeta_xmp_property_new:nnnnn \@@_xmp_property_new:nnnnn
+%    \end{macrocode}
+% \end{macro}
 % 
 % \begin{macro}{\pdfmeta_xmp_add_declaration:n,\pdfmeta_xmp_add_declaration:e}
 %    \begin{macrocode}





More information about the latex3-commits mailing list.