extract more svg metadata

This commit is contained in:
Jean-Francois Dockes 2013-03-28 08:49:40 +01:00
parent 838ea6d623
commit 2018ef76b8
3 changed files with 38 additions and 2 deletions

View File

@ -84,6 +84,7 @@ xsltproc --novalid --nonet - "$infile" <<EOF
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:dc="http://purl.org/dc/elements/1.1/"
exclude-result-prefixes="svg"
>
@ -94,6 +95,9 @@ xsltproc --novalid --nonet - "$infile" <<EOF
<head>
<xsl:apply-templates select="svg:svg/svg:title"/>
<xsl:apply-templates select="svg:svg/svg:desc"/>
<xsl:apply-templates select="svg:svg/svg:metadata/descendant::dc:creator"/>
<xsl:apply-templates select="svg:svg/svg:metadata/descendant::dc:subject"/>
<xsl:apply-templates select="svg:svg/svg:metadata/descendant::dc:description"/>
</head>
<body>
<xsl:apply-templates select="//svg:text"/>
@ -111,6 +115,36 @@ xsltproc --novalid --nonet - "$infile" <<EOF
</xsl:text>
</xsl:template>
<xsl:template match="dc:creator">
<meta>
<xsl:attribute name="name">author</xsl:attribute>
<xsl:attribute name="content">
<xsl:value-of select="."/>
</xsl:attribute>
</meta><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="dc:subject">
<meta>
<xsl:attribute name="name">keywords</xsl:attribute>
<xsl:attribute name="content">
<xsl:value-of select="."/>
</xsl:attribute>
</meta><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="dc:description">
<meta>
<xsl:attribute name="name">description</xsl:attribute>
<xsl:attribute name="content">
<xsl:value-of select="."/>
</xsl:attribute>
</meta><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="svg:title">
<title><xsl:value-of select="."/></title><xsl:text>
</xsl:text>

View File

@ -179,7 +179,10 @@ class Doc {
} else if (mit->second.empty()) {
mit->second = value;
} else {
mit->second += string(" - ") + value;
// It may happen that the same attr exists several times
// in the internfile stack. Avoid duplicating values.
if (mit->second != value)
mit->second += string(" - ") + value;
}
return true;
}

View File

@ -39,7 +39,6 @@ abstract = XS
caption = S
title = S
subject = S
author = A
keywords= K
xapyear = Y
xapyearmon = M