-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform.xsl
32 lines (26 loc) · 938 Bytes
/
transform.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:t="http://ntcir-math.nii.ac.jp/">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:text>QueryID;TeXQuery </xsl:text>
<xsl:apply-templates select="./*"/>
</xsl:template>
<xsl:template match="/t:topics/t:topic">
<xsl:variable name="name" select="./t:num"/>
<xsl:analyze-string select="$name" regex="NTCIR(\d+)-Math-(\d+)">
<xsl:matching-substring>
<xsl:value-of select="regex-group(2)"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="$name"/>
</xsl:non-matching-substring>
</xsl:analyze-string>
<xsl:text>;$</xsl:text>
<xsl:value-of select="./t:query/t:formula/m:math/m:semantics/m:annotation"/>
<xsl:text>$ </xsl:text>
</xsl:template>
</xsl:stylesheet>