XSLTOperation to edit MathML
Posted: Fri Apr 16, 2021 4:25 am
I'm creating an Author action to add a label to a MathML element.
Following the models at https://www.oxygenxml.com/doc/versions/ ... tions.html, my transformation script looks like this:
I have two questions:
1. Although the XSLTOperation action seems to run the script without errors, when I have it open in Oxygen I get a parsing error: "Cannot find a 0-argument function named Q{http://www.oxygenxml.com/ns/author/xpat ... nt-element()" Is this a bug?
2. The text "(#)" inside the <mml:mtext> element is just a placeholder for the actual label, e.g., "(1)" or "(2)" or "(14.1)", etc. I was hoping to use the editor variable ${ask} to request the actual label from the user, but I don't seem to have the syntax right. E.g., <xsl:value-of select="${ask('Enter label', generic)}"/> doesn't work. Is there a way to do this?
Following the models at https://www.oxygenxml.com/doc/versions/ ... tions.html, my transformation script looks like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:oxy="http://www.oxygenxml.com/ns/author/xpath-extension-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs oxy"
version="2.0">
<xsl:template match="/">
<xsl:apply-templates select="oxy:current-element()"/>
</xsl:template>
<xsl:template match="mml:math">
<xsl:element name="mml:math">
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<mml:mrow>
<mml:mtable>
<mml:mlabeledtr>
<mml:mtd>
<mml:mtext>(#)</mml:mtext>
</mml:mtd>
<mml:mtd>
<xsl:apply-templates/>
</mml:mtd>
</mml:mlabeledtr>
</mml:mtable>
</mml:mrow>
</xsl:element>
</xsl:template>
<!-- catchall -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
1. Although the XSLTOperation action seems to run the script without errors, when I have it open in Oxygen I get a parsing error: "Cannot find a 0-argument function named Q{http://www.oxygenxml.com/ns/author/xpat ... nt-element()" Is this a bug?
2. The text "(#)" inside the <mml:mtext> element is just a placeholder for the actual label, e.g., "(1)" or "(2)" or "(14.1)", etc. I was hoping to use the editor variable ${ask} to request the actual label from the user, but I don't seem to have the syntax right. E.g., <xsl:value-of select="${ask('Enter label', generic)}"/> doesn't work. Is there a way to do this?