]> CRI, Mines Paris - PSL - Photo.git/blobdiff - Products/Photo/xslt/xmp_merge_descriptions.xsl
eggification
[Photo.git] / Products / Photo / xslt / xmp_merge_descriptions.xsl
diff --git a/Products/Photo/xslt/xmp_merge_descriptions.xsl b/Products/Photo/xslt/xmp_merge_descriptions.xsl
new file mode 100644 (file)
index 0000000..5d7ddd8
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0"
+               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+               xmlns:x="adobe:ns:meta/"
+               xmlns:xmpTPg="http://ns.adobe.com/xap/1.0/t/pg/"
+               xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
+               xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/DynamicMedia/"
+               xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/"
+               xmlns:exif="http://ns.adobe.com/exif/1.0/"
+               xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
+               xmlns:xap="http://ns.adobe.com/xap/1.0/"
+               xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
+               xmlns:dc="http://purl.org/dc/elements/1.1/"
+               xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
+               xmlns:xmpBJ="http://ns.adobe.com/xap/1.0/bj/"
+               xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
+               xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"
+               xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
+               xmlns:pdf="http://ns.adobe.com/pdf/1.3/"
+               xmlns:xmp="http://ns.adobe.com/xap/1.0/">
+
+  <xsl:output encoding="UTF-8" indent="yes" method="xml" />
+
+  <xsl:template match="*">
+    <xsl:element name="{name(.)}">
+       <xsl:for-each select="@*">
+        <xsl:attribute name="{name(.)}">
+          <xsl:value-of select="."/>
+        </xsl:attribute>
+       </xsl:for-each>
+       <xsl:choose>
+        <xsl:when test="name(.) = 'rdf:RDF' and count(rdf:Description)&gt;1">
+          <xsl:call-template name="fuse-descriptions" />
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates />
+        </xsl:otherwise>
+       </xsl:choose>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template name="fuse-descriptions">
+    <rdf:Description rdf:about="{rdf:Description[1]/rdf:about}">
+       <xsl:for-each select="rdf:Description">
+         <xsl:for-each select="@*[name(.)!='rdf:about']">
+           <xsl:attribute name="{name(.)}">
+             <xsl:value-of select="."/>
+           </xsl:attribute>
+         </xsl:for-each>
+         <xsl:copy-of select="*"/>
+       </xsl:for-each>
+    </rdf:Description>
+  </xsl:template>
+
+</xsl:stylesheet>