Passing Parameters to the XSLT Export Filter
Gannon Dick <[email protected]> Fri, 16 Oct 2009 01:57:01 -0700 (PDT)
| Newsgroups | gmane.comp.openoffice.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
Now (OO version 3.1) that the number of User Defined Properties == Custom Properties is not limited to 4, it is practical to use Properties to pass parameters to the XSLT Export Filter.
File>>Properties>>Custom Properties(tab) Add
e.g. SAX.test = 'Hello World" (text)
(mavens be gone! There are lots of ways to do this)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
xmlns:saxon="http://www.w3.org/1999/XSL/Transform#"
exclude-result-prefixes="meta">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:param name="SAX.test">
<xsl:for-each select="//meta:user-defined">
<xsl:if test="./@meta:name = 'SAX.test'">
<xsl:value-of select="./." />
</xsl:if>
</xsl:for-each>
</xsl:param>
<xsl:template match="/">
<saxon:param>
<xsl:value-of select="$SAX.test" />
</saxon:param>
</xsl:template>
</xsl:stylesheet>
output is:
<?xml version="1.0" encoding="UTF-8"?>
<saxon:param xmlns:saxon="http://www.w3.org/1999/XSL/Transform#">
Hello World !
</saxon:param>
Hints:
a) parameter names have to be QNAMES - no spaces
b) the "dot" notation is probably a good idea so you can easily take the parameters out of the list of properties, but it's not required (Svante, what do you think ? An XSL template for this "protocol" would be nice, in your spare time)
c) tagged Personally Identifiable Information (PII) and other information which should be redacted/deleted (or not) from output documents does not require two transforms **provided** you can pass a (redact/keep) parameter to the stylesheet. See: http://purl.org/pii/terms/
--Gannon