github.com/matislovas/ratago@v0.0.0-20240408115641-cc0857415a7a/xslt/testdata/general/bug-142.xsl (about) 1 <?xml version="1.0" encoding="UTF-8"?> 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:g="http://glandium.org/" xmlns:日本語="http://glandium.org/nihongo/" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="g 日本語 date"> 3 4 <xsl:template match="g:posts"> 5 <html xml:lang="fr"> 6 <body> 7 <xsl:apply-templates select="*"/> 8 </body> 9 </html> 10 </xsl:template> 11 12 <xsl:template match="g:posts/g:post[g:date]"> 13 <xsl:variable name="id" select="@id"/> 14 <xsl:variable name="date" select="concat(substring(g:date,1,4),'/',substring(g:date,5,2),'/',substring(g:date,7,2))"/> 15 16 <div id="post{$id}"> 17 <xsl:if test="lang(ja)"> 18 <xsl:attribute name="xml:lang">ja</xsl:attribute> 19 </xsl:if> 20 <h3><a href="{$date}/{$id}"> 21 <xsl:apply-templates select="g:title"/> 22 </a></h3> 23 <xsl:apply-templates select="g:content"/> 24 </div> 25 </xsl:template> 26 27 <xsl:template match="g:post/g:title"> 28 <xsl:apply-templates mode="日本語" select="."/> 29 </xsl:template> 30 31 <xsl:template match="g:post/g:content"> 32 <xsl:apply-templates/> 33 </xsl:template> 34 35 <xsl:template match="g:content/g:para"> 36 <p><xsl:apply-templates mode="link" select="."/></p> 37 </xsl:template> 38 39 <xsl:template match="g:para/g:span|g:item/g:span|g:span/g:span"> 40 <xsl:apply-templates mode="link" select="."/> 41 </xsl:template> 42 43 <xsl:template match="g:content/g:list|g:item/g:list"> 44 <ul><xsl:apply-templates mode="link" select="."/></ul> 45 </xsl:template> 46 47 <xsl:template match="g:list/g:item"> 48 <li><xsl:apply-templates mode="link" select="."/></li> 49 </xsl:template> 50 51 <xsl:template match="g:span[@href]|g:para[@href]|g:item[@href]" mode="link"> 52 <a href="{@href}"> 53 <xsl:apply-templates mode="日本語" select="."/> 54 </a> 55 </xsl:template> 56 57 <xsl:template match="*" mode="link"> 58 <xsl:apply-templates mode="日本語" select="."/> 59 </xsl:template> 60 61 <xsl:template match="*" mode="日本語"> 62 <xsl:apply-templates/> 63 </xsl:template> 64 65 <xsl:template match="*[lang('ja') and not(ancestor::*[@xml:lang='ja'])]" mode="日本語"> 66 <xsl:apply-templates/> 67 </xsl:template> 68 69 <xsl:template match="g:span[lang('ja') and not (ancestor::*[@xml:lang='ja'])][not(@href)]" mode="日本語"> 70 <span xml:lang="ja"> 71 <xsl:apply-templates/> 72 </span> 73 </xsl:template> 74 75 <xsl:template match="*[lang('fr')]" mode="日本語"> 76 <xsl:apply-templates/> 77 </xsl:template> 78 79 <xsl:template match="g:span[lang('fr')][not(@href)]" mode="日本語"> 80 <span xml:lang="fr"> 81 <xsl:apply-templates/> 82 </span> 83 </xsl:template> 84 85 </xsl:stylesheet>