Skip to content

Commit

Permalink
Introduce XPath function to convert to upper/lower case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarrano committed Apr 3, 2019
1 parent 66d7691 commit f061e42
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion antidox/templates/compound.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<xsl:param name="key-word" select="name"/>
<xsl:if test="not($noindex)">
<antidox:index>
<xsl:attribute name="key"><xsl:value-of select="substring($key-word, 1, 1)"/></xsl:attribute>
<xsl:attribute name="key"><xsl:value-of select="antidox:upper-case(substring($key-word, 1, 1))"/></xsl:attribute>
</antidox:index>
</xsl:if>
</xsl:template>
Expand Down
12 changes: 12 additions & 0 deletions antidox/xtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def _f(ctx, nodes_or_text):
_basic_ns = ET.FunctionNamespace("antidox")


@_basic_ns("upper-case")
@_textfunc
def _upper_case(text):
return text.upper()


@_basic_ns("lower-case")
@_textfunc
def _lower_case(text):
return text.lower()


@_basic_ns("string-to-ids")
@_textfunc
def _string_to_ids(text):
Expand Down
10 changes: 10 additions & 0 deletions doc/source/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ XPath extension functions
the "initial" letter correctly for the index.


.. xpath-func:: antidox:lower-case(node_or_text)

Convert text to lower-case (similar to the same name function in XPath 2.0.)


.. xpath-func:: antidox:upper-case(node_or_text)

Convert text to upper-case (similar to the same name function in XPath 2.0.)


antidox-specific (pseudo)elements
---------------------------------

Expand Down

0 comments on commit f061e42

Please sign in to comment.