Closed streino closed 2 weeks ago
Do we want to handle N parameters? And configure how many (and which) parameters a transformation expects?
Or maybe we start with one unnamed parameter. But we still need to configure which transformation expects a parameter.
Do we want to handle N parameters?
Not sure yet how many params we'll need. We can start with one if we want, I expect it'll be the most frequent case.
And configure how many (and which) parameters a transformation expects?
XSLT params are children of the top-level xsl:stylesheet
root. Best way IMO is get those from the parse tree. We get the name and default value that way. Maybe lxml even has some specific way to get those, since it has to know how to set them.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
<xsl:param name="myparam" select="'foo'"/>
...
This could be a good test case (change-language
with a parameter):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:geonet="http://www.fao.org/geonetwork"
exclude-result-prefixes="#all">
<xsl:param name="language" select="'eng'"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/gmd:MD_Metadata/gmd:language/gco:CharacterString/text()">
<xsl:value-of select="$language"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This could be a good test case (
change-language
with a parameter):
Yes ! That was the idea ;)
Nitpick, <xsl:strip-space elements="*"/>
usually stays at the top.
Some XSL will require parameters set by the user. Cf eg https://ecospheres.gitbook.io/recommandations-iso-dcat/adaptation-des-metadonnees-iso-19139-pour-faciliter-la-transformation-en-dcat/rendre-les-distributions-identifiables would require some sort of pattern matching dependent on the targeted catalog.