<t:stylesheet version="1.0" 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:t="http://www.w3.org/1999/XSL/Transform" 
    xmlns:daml="http://www.daml.org/2001/03/daml+oil#" 
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:svga="http://infomesh.net/2002/svgaccess/#" 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >

<t:param name="idlist"/>

<t:template match="/">
   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
       <title>SVG Linearization Output</title>
       <style type="text/css">
           body { margin: 1em; font-family: Arial, Heveltica, sans-serif; }
           h1 { font-family: Tahoma; }
           div.svg { padding: 0.7em 1em; border-left: 0.3em solid #8080b0; 
                     margin: 0.8em; }
           p.desc { font-size: 0.9em; color: #336699; }
           span.desc { font-size: 0.8em; color: #6699cc; }
       </style>
     </head>
     <body>
       <h1>
         <t:choose>
            <t:when test="/svg:svg/svg:title">
              <t:value-of select="/svg:svg/svg:title/text()" />
            </t:when>
            <t:otherwise>SVG Linearization Output</t:otherwise>
         </t:choose>
        </h1>
        <t:for-each select="/svg:svg/svg:desc"><p class="desc">
           Description: <t:value-of select="(.)"/>
        </p></t:for-each>
        <div class="svg"><t:apply-templates/></div>
        <p>[Transformed by <a href="svg2xhtml.xsl">svg2xhtml</a>].</p>
        <address>
           <a href="http://purl.org/net/sbp/">Sean B. Palmer</a>
        </address>
     </body>
   </html>
</t:template>

<t:template 
   match="//rdf:Description[@rdf:about='']/svga:linearizesAs//daml:first">
<t:variable name="rawid"><t:value-of select="(@rdf:resource)"/></t:variable>

<t:variable name="id">
<t:if test="contains($rawid,'#')"><t:value-of 
select="substring-after($rawid,'#')"/></t:if>
</t:variable>

<t:choose>
<t:when test="//svga:Inline[@rdf:about=$rawid]">
<span id="{$id}"><!-- Linearization -->
<t:if test="//*[@id=$id]/svg:desc">
<t:attribute name="title">Description: 
<t:for-each select="//*[@id=$id]/svg:desc">
   <t:value-of select="(.)" />
</t:for-each>
</t:attribute>
</t:if>
<t:for-each select="//*[@id=$id]/svg:text">
   <t:value-of select="(.)" /><t:text> </t:text>
</t:for-each>
</span>
</t:when>
<t:otherwise>
<div id="{$id}"><!-- Linearization -->
<t:for-each select="//*[@id=$id]/svg:text">
   <t:value-of select="(.)" />
</t:for-each>
<t:if test="//*[@id=$id]/svg:desc">
<t:text> </t:text>
<span class="desc">(desc: <t:for-each select="//*[@id=$id]/svg:desc">
   <t:value-of select="(.)" />
</t:for-each>)</span>
</t:if>
</div>
</t:otherwise>
</t:choose>
</t:template>

<!-- Don't pass text through -->
<t:template match="text()|@*">
</t:template>
</t:stylesheet>
