view xsls/link.xsls @ 32:2bcfb5f75e06

Supporting new format of <module> and <section>: <module name="..." ...> and <section id="..." name="..."> Old format should be eventually removed.
author Igor Sysoev <igor@sysoev.ru>
date Fri, 30 Sep 2011 13:13:21 +0000
parents 9d3403f5204d
children 666e85596e3c
line wrap: on
line source

X:stylesheet {


<!-- {a href="/en/docs/page.xml" /} -->

X:template = "a[starts-with(@href, '/')
                and string() = ''
                and contains(@href, '.xml')]"
{
    <a>
    X:attribute "href" {

        <!--
          --  variables are not allowed in a template match predicate:
          --     a[starts-with(@href, $DIRNAME) ... ]
          --  therefore, we have to test this using "if"
          -->

        X:if "starts-with(@href, $DIRNAME)" {

           <!-- convert to a link "docs/page.html" -->

           !{ substring-after(document(concat($XML, @href))/article/@link
                              |document(concat($XML, @href))/module/@link,
                              $DIRNAME) }
        } else {

           <!-- convert to a link "../../../en/docs/page.html" -->

           !{ concat($ROOT, document(concat($XML, @href))/article/@link
                            |document(concat($XML, @href))/module/@link) }
        }
    }
    !{  document(concat($XML, @href))/article/@title
       |document(concat($XML, @href))/article/@name
       |document(concat($XML, @href))/module/@title
       |document(concat($XML, @href))/module/@name }
    </a>
}


<!-- {a href="/en/docs/page.xml"} TEXT {/a} -->

X:template = "a[starts-with(@href, '/')
                and string()
                and contains(@href, '.xml')]"
{
    <a>
    X:attribute "href" {
        X:if "starts-with(@href, $DIRNAME)" {
           !{ substring-after(document(concat($XML, @href))/article/@link
                              |document(concat($XML, @href))/module/@link,
                              $DIRNAME) }
        } else {
           !{ concat($ROOT, document(concat($XML, @href))/article/@link
                            |document(concat($XML, @href))/module/@link) }
        }
    }
    !!;
    </a>
}

X:template = "a" { <a href="{@href}"> !!; </a> }

X:template = "img" { <img src="{@href}"> !!; </img> }

}