Page 1 of 1

XSLT 2.0 group-by: grouping/w processing of text node

Posted: Thu Mar 22, 2007 2:38 pm
by kellner
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:

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>
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.

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>
I'd very much appreciate advice.

Thanks in advance, [/list]

Re: XSLT 2.0 group-by: grouping/w processing of text node

Posted: Thu Mar 22, 2007 4:48 pm
by sorin_ristache
Hello,
kellner wrote:This code is to be transformed into LaTeX source code for typesetting.
The transformation is to achieve:
I think you can receive more useful answers if you post an example of the output file.


Regards,
Sorin

Posted: Thu Mar 22, 2007 10:53 pm
by kellner
Ok, here's a sample of the LaTeX file:

Code: Select all

 

\documentclass[a4paper,twoside,10pt]{book}
\usepackage[cjkjis]{ucs}
\usepackage[german]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{ledmac}
\usepackage{multibbl}
\usepackage{ulem} \onehalfspacing \PrerenderUnicode{ñ} \titleformat*{\section}{\sc}
\titleformat*{\subsection}{\sc} \setlength{\parindent}{12pt} \setlength{\headheight}{15pt}

\usepackage[left=2cm, right=8cm, top=5cm, bottom=5cm]{geometry} \pagestyle{fancy}
\fancyhead{} \fancyfoot{} \fancyfoot[CE,CO]{\today} \setlength{\stanzaindentbase}{12pt}
\setstanzaindents{1,1,1} \setstanzapenalties{1,5000,5000,5000} \let\endstanzaextra=\medbreak
\footparagraph{A} \footparagraph{B} \footparagraph{C} \footparagraph{D}
\renewcommand{\notenumfont}{\bfseries}\renewcommand*{\notefontsetup}{%
\def\baselinestretch{1.0}% \footnotesize}

\begin{document}
\lineation{page} \linenummargin{inner}
\firstlinenum{0} \linenumincrement{5} \beginnumbering

\pstart
\textbf{451}
\par
\edtext{atha}{\lemma{atha}{\Afootnote{
atha Pr-A, Pr-B (Pr-2); }}} notpadyate tasmān na ca \edtext{tatpratibhāsinī}{\lemma{tatpratibhāsinī}{\Afootnote{
tatpratibhāsinī Pr-A, Pr-B (Pr-2); }}} $|$\\ \indent
sā \edtext{dhīr nirviṣayā }{\lemma{dhīr nirviṣayā }{\Afootnote{
dhīr nirviṣayā M-A, Pr-A (Pr-2); dhīr\underline{nirvi}ṣayā Pr-B; }}} prāptā sāmānyaṃ ca \edtext{tadagrahe}{\lemma{tadagrahe}{\Afootnote{
tad?grahe Pr-A; tadagrahe Pr-B; }}} $||$

\par

\pend
\endnumbering
\end{document}

[\code]