I need to detect the first title element and print out a special comment before this first title element.
<xsl:template match="title[string-length(.) > 0]" mode="content">
<xsl:comment>%title id="<xsl:value-of select="."/>"%</xsl:comment>
</xsl:template>
I can detect these title elements, but what i've got to do to count and get this special comment before the first title element?
EDIT: Thanks for the comments, but i can't get it to work unfortunatly. So additionally i add the XML source here, maybe someone could point me to en elegant solution?
<body id="EL_bodyN10001"><text id="EL_textN10001"><page id="EL_pageN10004"><p id="EL_pN10006"></p><p id="EL_pN10012">lorem ipsum dolor sit</p><p id="EL_pN10045">msdfsdkfh sdfsfksd sfsdfsdfsdfdsfh <strong id="EL_strongN1004C">LOREM IPSUM</strong>. lorem aklsjd asda sdasjdlkjaksld</p>
<title id="EL_titleN10001">my first title here</title>
<subheading id="EL_subheadingN1006E" level="1">MY FIRST SUBHEADING</subheading><p id="EL_pN10075">sdfjlksjfsjdf sfsjfljsdf sfklöskdfö sdfölksföksölf sdfksfk</p><p id="EL_pN10084">tzputozu lultpülupützu tultlutzulztu wewe rrtrt.</p><title id="EL_titleN10001">my second title</title><subheading id="EL_subheadingN100D9" level="1">THIS IS MY SECONT SUBHEADING</subheading><p id="EL_pN100E0">this is another senseless paragraph test.</p></page></text></body>
titleelements siblings of the same parent? Thenmatch="title[normalize-space()][1]"suffices. Or you could check there is nopreceding::title. - Martin Honnen