aboutsummaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2004-03-30 06:16:21 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2004-03-30 06:16:21 +0000
commit0ab8bd00ea9c111ac32b6af721242e8a3fc86823 (patch)
treea089f69a3712bf0bd4e95dd015dd3a52feb48e38 /security
parent58b6bd18b02e1a940092a4348af9c051a15115bb (diff)
downloadports-0ab8bd00ea9c111ac32b6af721242e8a3fc86823.tar.gz
ports-0ab8bd00ea9c111ac32b6af721242e8a3fc86823.zip
Notes
Diffstat (limited to 'security')
-rw-r--r--security/vuxml/Makefile3
-rw-r--r--security/vuxml/files/tidy.sh18
-rw-r--r--security/vuxml/files/tidy.xsl122
3 files changed, 143 insertions, 0 deletions
diff --git a/security/vuxml/Makefile b/security/vuxml/Makefile
index b9d60c8629f1..56effd511a28 100644
--- a/security/vuxml/Makefile
+++ b/security/vuxml/Makefile
@@ -78,4 +78,7 @@ do-install:
validate:
@${SH} ${FILESDIR}/validate.sh "${VUXML_FILE}"
+tidy:
+ @${SH} ${FILESDIR}/tidy.sh "${FILESDIR}/tidy.xsl" "${VUXML_FILE}"
+
.include <bsd.port.mk>
diff --git a/security/vuxml/files/tidy.sh b/security/vuxml/files/tidy.sh
new file mode 100644
index 000000000000..5e0c855835d4
--- /dev/null
+++ b/security/vuxml/files/tidy.sh
@@ -0,0 +1,18 @@
+#! /bin/sh
+tidy_file="$1"
+vuxml_file="$2"
+if [ -z "${vuxml_file}" -o -z "${tidy_file}" ]; then
+ exec >&2
+ echo "Usage: tidy.sh /path/to/vuxml/document /path/to/tidy.xsl"
+ exit 1
+fi
+
+X=`/usr/bin/which xsltproc`
+if [ -z "$X" ]; then
+ exec >&2
+ echo "Could not find \`xsltproc\'."
+ echo "Install ports/textproc/libxslt."
+ exit 1
+fi
+
+xsltproc --novalid "${tidy_file}" "${vuxml_file}"
diff --git a/security/vuxml/files/tidy.xsl b/security/vuxml/files/tidy.xsl
new file mode 100644
index 000000000000..3a9febbbf2c8
--- /dev/null
+++ b/security/vuxml/files/tidy.xsl
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:vuxml="http://www.vuxml.org/apps/vuxml-1"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ exclude-result-prefixes="vuxml xhtml"
+ >
+
+<xsl:param name="upper" select="'ABCDEF'" />
+<xsl:param name="lower" select="'abcdef'" />
+
+<xsl:output
+ method="xml"
+ encoding="utf-8"
+ doctype-system="http://www.vuxml.org/dtd/vuxml-1/vuxml-10.dtd"
+ doctype-public="-//vuxml.org//DTD VuXML 1.0//EN"
+ indent="yes"
+ />
+
+<!--
+All this special care is needed so that we can control the
+output of namespace declarations. Using copy/copy-of may
+result in more namespace declarations than we wish.
+-->
+
+<xsl:template match="/">
+ <xsl:apply-templates />
+</xsl:template>
+
+<!-- Copy processing instructions and comments, too. -->
+<xsl:template match="processing-instruction()|comment()">
+ <xsl:copy>
+ <xsl:apply-templates />
+ </xsl:copy>
+</xsl:template>
+
+<!--
+Set the namespace on the <vuxml> element. Sort the <vuln> elements
+in descending order of their <modified> elements (or <entry>, if they
+don't have <modified>). Insert an empty line between <vuln> elements.
+-->
+<xsl:template match="vuxml:vuxml">
+ <xsl:element name="{name()}">
+ <xsl:attribute
+ name="xmlns">http://www.vuxml.org/apps/vuxml-1</xsl:attribute>
+ <xsl:for-each select="@*">
+ <xsl:attribute name="{name()}"><xsl:value-of
+ select="." /></xsl:attribute>
+ </xsl:for-each>
+ <xsl:for-each select="vuxml:vuln">
+ <xsl:sort
+ order="descending"
+ select="vuxml:dates/*[last()]/text()" />
+ <xsl:text disable-output-escaping="yes">&#10;&#32;&#32;</xsl:text>
+ <xsl:apply-templates select="." />
+ <xsl:text disable-output-escaping="yes">&#10;</xsl:text>
+ </xsl:for-each>
+ </xsl:element>
+</xsl:template>
+
+<!--
+Many elements have only text content. Strip extraneous whitespace
+from those elements.
+-->
+<xsl:template match="vuxml:topic|vuxml:name|vuxml:le|vuxml:lt|
+ vuxml:ge|vuxml:gt|vuxml:eq|vuxml:cvename|vuxml:url|vuxml:bid|
+ vuxml:certsa|vuxml:certvu|vuxml:uscertsa|vuxml:uscertta|
+ vuxml:mlist|vuxml:freebsdsa|vuxml:freebsdpr|vuxml:discovery|
+ vuxml:entry|vuxml:modified">
+ <xsl:call-template name="normalize-space">
+ <xsl:with-param name="node" select="." />
+ </xsl:call-template>
+</xsl:template>
+
+
+<!-- Include a namespace declaration on the <body> element. -->
+<xsl:template match="xhtml:body">
+ <xsl:element name="{name()}">
+ <xsl:attribute
+ name="xmlns">http://www.w3.org/1999/xhtml</xsl:attribute>
+ <xsl:call-template name="copy-attr">
+ <xsl:with-param name="node" select="." />
+ </xsl:call-template>
+ <xsl:apply-templates />
+ </xsl:element>
+</xsl:template>
+
+<!-- Default copy. -->
+<xsl:template match="*">
+ <xsl:element name="{name()}">
+ <xsl:call-template name="copy-attr">
+ <xsl:with-param name="node" select="." />
+ </xsl:call-template>
+ <xsl:apply-templates />
+ </xsl:element>
+</xsl:template>
+
+<!-- Copy attributes, but fold VuXML IDs (vid) to lower case. -->
+<xsl:template name="copy-attr">
+ <xsl:param name="node" />
+ <xsl:if test="$node/@vid">
+ <xsl:attribute name="vid"><xsl:value-of
+ select="translate(@vid,$upper,$lower)" /></xsl:attribute>
+ </xsl:if>
+ <xsl:for-each select="$node/@*[name() != 'vid']">
+ <xsl:attribute name="{name()}"><xsl:value-of
+ select="." /></xsl:attribute>
+ </xsl:for-each>
+</xsl:template>
+
+<!-- Strip whitespace from elements with only text -->
+<xsl:template name="normalize-space">
+ <xsl:param name="node" />
+ <xsl:element name="{name($node)}">
+ <xsl:call-template name="copy-attr">
+ <xsl:with-param name="node" select="$node" />
+ </xsl:call-template>
+ <xsl:value-of select="normalize-space($node/text())" />
+ </xsl:element>
+</xsl:template>
+
+</xsl:stylesheet>