XSLT 2.0 group-by: grouping/w processing of text node
Posted: Thu Mar 22, 2007 2:38 pm
Hello,
I'm new to the XSLT 2.0 "group-by" method and was wondering whether someone could help me with the following task.
I have XML code that's structured like this:
This code is to be transformed into LaTeX source code for typesetting.
The transformation is to achieve:
1) output text content of <lem>-element
2) group <rdg> elements on the basis of their text content. In the above example, the result should be "dhīr nirviṣayā Pr-A, M-A; \underline{dhīr} ni\underline{r}viṣayā Pr-B".
2) Further conditional processing of <rdg> elements on the basis of attribute values. If the attribute "type" has the value "edition", the value of the attribute "wit" is to be enclosed in brackets, i.e. the above example should actually be ""dhīr nirviṣayā Pr-A, M-A (Pr-2); \underline{dhīr} ni\underline{r}viṣayā Pr-B".
The text content of the rdg-element can contain further nodes that require processing, like, in this example, <unclear> that should be transformed into underlined text.
I was thus far able to perform the basic grouping operation, but I'm not sure how to call templates for further sub-processing of the grouped nodes, nor how to apply further conditions on <rdg>-attributes.
I'd very much appreciate advice.
Thanks in advance, [/list]
I'm new to the XSLT 2.0 "group-by" method and was wondering whether someone could help me with the following task.
I have XML code that's structured like this:
Code: Select all
<app type="critical">
<lem>dhīr nirviṣayā </lem>
<rdg varSeq="1" wit="M-A" type="witness-pratika">dhīr nirviṣayā</rdg>
<rdg varSeq="1" wit="Pr-A">dhīr nirviṣayā</rdg>
<rdg varSeq="2" wit="Pr-B"><unclear reason="out-of-focus">dhīr</unclear> ni<unclear reason="out-of-focus">r</unclear>viṣayā </rdg>
<rdg type="edition" varSeq="1" wit="Pr-2">dhīr nirviṣayā</rdg>
</app>
The transformation is to achieve:
1) output text content of <lem>-element
2) group <rdg> elements on the basis of their text content. In the above example, the result should be "dhīr nirviṣayā Pr-A, M-A; \underline{dhīr} ni\underline{r}viṣayā Pr-B".
2) Further conditional processing of <rdg> elements on the basis of attribute values. If the attribute "type" has the value "edition", the value of the attribute "wit" is to be enclosed in brackets, i.e. the above example should actually be ""dhīr nirviṣayā Pr-A, M-A (Pr-2); \underline{dhīr} ni\underline{r}viṣayā Pr-B".
The text content of the rdg-element can contain further nodes that require processing, like, in this example, <unclear> that should be transformed into underlined text.
I was thus far able to perform the basic grouping operation, but I'm not sure how to call templates for further sub-processing of the grouped nodes, nor how to apply further conditions on <rdg>-attributes.
Code: Select all
<xsl:template match="note/app">
<xsl:choose>
<xsl:when test="@type = 'critical'"><xsl:for-each select="child::lem">{\lemma{<xsl:apply-templates/>}</xsl:for-each>{\Afootnote{<xsl:for-each-group select="rdg" group-by="."><xsl:sort select="@varSeq"/>
<xsl:copy-of select="current-grouping-key( )"/>&space;
<xsl:value-of select="current-group()/@wit" separator=", "/>; </xsl:for-each-group>}}} </xsl:when>
</xsl:choose>
</xsl:template>
Thanks in advance, [/list]