<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
	xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"
	xmlns:xlink="http://ww.w3.org/TR/xlink"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	exclude-result-prefixes="xinclude xlink"
	version="1.0">

<xsl:output method="xml" 
	    encoding="utf-8"
	    doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
	    doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml"/>

	
<xsl:template match="/">
	<wml>
	   <xsl:apply-templates />
	</wml>
</xsl:template>

<xsl:template match="topic[@xlink:type='extended']">
  <card>
   <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
   <xsl:attribute name="title"><xsl:value-of select="@xlink:title"/></xsl:attribute>
   <xsl:apply-templates select="xinclude:include" />
   <p>
	<em>My portal Headlines</em>
	<select name="type" title="Mobile Portal">
		<xsl:for-each select="topic[@xlink:type='locator']">
			<option>
				<xsl:attribute name="value"><xsl:value-of select="@id"/></xsl:attribute>
				<xsl:attribute name="onpick">#<xsl:value-of select="@id"/></xsl:attribute>
				<xsl:value-of select="@xlink:title"/>
			</option>
		</xsl:for-each>
	</select>
   </p>
  </card>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="abstract">
	<card>
		<xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
		<p>
			<xsl:value-of select="."/>
		</p>
	</card>
</xsl:template>

<xsl:template match="xinclude:include">
	<xsl:apply-templates select="document(@href)/topic-list"/>
</xsl:template>

</xsl:stylesheet>
