<?xml version="1.0" encoding="utf-8"?>
<!-- 

    Copyright (C) 2006 W3C (R) (MIT ERCIM Keio), All Rights Reserved.
    W3C liability, trademark and document use rules apply.

    http://www.w3.org/Consortium/Legal/ipr-notice
    http://www.w3.org/Consortium/Legal/copyright-documents

    $Header: /w3ccvs/WWW/2002/ws/databinding/edcopy/patterns/explode_overviews.xsl,v 1.14 2008/03/18 08:11:01 pdowney Exp $

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.w3.org/2002/ws/databinding/patterns/6/09/"
    xmlns:ex="http://www.w3.org/2002/ws/databinding/examples/6/09/"
    exclude-result-prefixes="">

    <xsl:import href="../common/xml-to-string.xsl"/>
    <xsl:import href="annotate-xml.xsl"/>
 
    <xsl:output method="html" name="overview" indent="yes" encoding="UTF-8"/>
    
    <xsl:param name="dir"/>
    <xsl:variable name="ns" select="'ex:'"/>
    <xsl:variable name="sep" select="'/'"/>
    <xsl:variable name="w3c.root">../../../../../../..</xsl:variable>
    <xsl:param name="examplesDir">../../examples/6/09/</xsl:param>
    <xsl:variable name="validation-results" select="document(concat($examplesDir, 'validation-results.xml'))/validation"/>
    
    <xsl:template match="/">
        <!--<xsl:apply-templates select="ex:examples/ex:example[@xml:id = 'StringElement']"/>-->
        <xsl:apply-templates select="ex:examples/ex:example"/>
    </xsl:template>
    
    <xsl:template match="ex:example">
        <xsl:param name="exampleId" select="@xml:id"/>
        <xsl:variable name="exampleElementId" select="@element"/> 
        <xsl:variable name="operation" select="concat('echo',$exampleId)"/>
        <xsl:variable name="element" select="$operation"/>
        
        <xsl:variable name="exampleDir" select="concat($dir,$sep,$exampleId,$sep)"/>
        <xsl:variable name="overviewFilename" select="'Overview.html'"/>
        <xsl:variable name="xsdFilename" select="concat( $exampleId , '.xsd' )"/>
        <xsl:variable name="echoxsdFilename" select="concat( 'echo', $exampleId , '.xsd' )"/>
        <xsl:variable name="wsdlFilename" select="concat( 'echo', $exampleId , '.wsdl' )"/>
        <xsl:variable name="wsdl20Filename" select="concat( 'echo', $exampleId , '-wsdl20.wsdl' )"/>
        <xsl:variable name="detectedPatternsFilename" select="concat( $exampleId , '-patterns.xml' )"/>

	<xsl:variable name="detectedPatternsPath" select="concat($exampleDir,$detectedPatternsFilename)"/>
	<xsl:variable name="detectedStatus"><xsl:value-of select="document($detectedPatternsPath)/detected/@status"/></xsl:variable>
        
        <xsl:result-document href="{$dir}{$sep}{$exampleId}{$sep}{$overviewFilename}" format="overview">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">
  <head>
    <title><xsl:value-of select="$exampleId"/> Example</title>
    <link type="text/css" rel="stylesheet" href="{$w3c.root}/StyleSheets/TR/base.css"/>
<style type="text/css">
div.exampleInner pre { margin-left: 1em;
                       margin-top: 0em; margin-bottom: 0em}
div.exampleInner { background-color: #d5dee3;
                   border-top-width: 4px;
                   border-top-style: double;
                   border-top-color: #d3d3d3;
                   border-bottom-width: 4px;
                   border-bottom-style: double;
                   border-bottom-color: #d3d3d3;
                   padding: 4px; margin: 0em }
pre { font-family: sans-serif }

table { empty-cells: show; }

th { color: #000000; background-color: #CCCC99; }

td { vertical-align: top; }

table caption {
	font-weight: normal;
	font-style: italic;
	text-align: left;
	margin-bottom: .5em;
}

<xsl:call-template name="annotate-xml-css"/>
</style>
<xsl:call-template name="annotate-xml-script"/>
  </head>

  <body xmlns:rddl="http://www.rddl.org/">

            <xsl:comment>

                Copyright (C) 2006 W3C (R) (MIT ERCIM Keio), All Rights Reserved.
                W3C liability, trademark and document use rules apply.
            
                http://www.w3.org/Consortium/Legal/ipr-notice
                http://www.w3.org/Consortium/Legal/copyright-documents
            
		Generated from: <xsl:value-of select="//ex:version"/><xsl:text>
</xsl:text>

            </xsl:comment>

    <div class="head">
      <p>

	<a href="http://www.w3.org/">
	  <img width="72" height="48" alt="W3C" src="{$w3c.root}/Icons/w3c_home"/>
	</a>
      </p>

      <h1><xsl:value-of select="$exampleId"/> Example </h1>
    </div>

	<div class="exampleInner">
<!--
	    <pre><xsl:attribute name="xml:space">preserve</xsl:attribute><xsl:apply-templates select="ex:types/* | ex:typedef/*" mode="pre"/></pre>
-->
	    <xsl:call-template name="annotate-xsd">
		<xsl:with-param name="document" select="document(concat($exampleDir,$xsdFilename))"/>
		<xsl:with-param name="patterns" select="document($detectedPatternsPath)"/>
		<xsl:with-param name="opts"><opts xmlns="" namespaces="0"/></xsl:with-param>
	    </xsl:call-template>
	</div>

	<p id="detectedPatterns">The <a href="../">example</a> schema [<a href="{$xsdFilename}"><xsl:value-of select="$xsdFilename"/></a>]
	    has been classified as being 

		<xsl:choose>
		    <xsl:when test="$detectedStatus = 'basic'">
			a <a href="{$w3c.root}/2002/ws/databinding/edcopy/basic/basic.html">Basic XML Schema Patterns for Databinding 1.0</a>
			<xsl:text> </xsl:text> 
			<a href="{$w3c.root}2002/ws/databinding/edcopy/advanced/advanced.html#document-conformance">conformant document</a>
			as it only 
		    </xsl:when>
		    <xsl:when test="$detectedStatus = 'advanced'" xml:space='preserve'>
			an <a href="{$w3c.root}/2002/ws/databinding/edcopy/advanced/advanced.html">Advanced XML Schema Patterns for Databinding 1.0</a>
			<xsl:text> </xsl:text> 
			<a href="{$w3c.root}/2002/ws/databinding/edcopy/advanced/advanced.html#document-conformance">conformant document</a>
			as it only 
		    </xsl:when>
		    <xsl:otherwise>
			"<xsl:value-of select="$detectedStatus"/>"
			as it
		    </xsl:otherwise>
		</xsl:choose>

	    <a href="{$detectedPatternsFilename}">exhibits</a> the following <a href="../../../../patterns/6/09/">patterns</a>:</p>

	<xsl:call-template name="detected-patterns-table">
	    <xsl:with-param name="patterns" select="document($detectedPatternsPath)"/>
	    <xsl:with-param name="exampleId" select="$exampleId"/>
	</xsl:call-template>

<!--
	<table border="1">
	<tr>
	    <th>Status</th>
	    <th>Name</th>
	    <th>XPath</th>
	</tr>
	
	<xsl:for-each select="document($detectedPatternsPath)/detected/pattern">
	    <tr>
		<td>
		<xsl:choose>
		    <xsl:when test="@status = 'basic' or @status = 'advanced'">
			<a href="{$w3c.root}/2002/ws/databinding/edcopy/{@status}/{@status}.html#pattern-{@name}"><xsl:value-of select="@status"/></a>
		    </xsl:when>
		    <xsl:otherwise>
			<xsl:value-of select="@status"/>
		    </xsl:otherwise>
		</xsl:choose>
		</td>
		<td><a href="{@pattern}"><xsl:value-of select="@name"/></a></td>
		<td>
		    <xsl:value-of select="@xpath"/>
		</td>
	    </tr>
	</xsl:for-each>

	</table>
-->

	<p>To facilitate testing, the example schema element has been wrapped in the following descriptions:</p>
	<ul>
	    <li><a href="{$xsdFilename}"><xsl:value-of select="$xsdFilename"/></a></li>
	    <li><a href="{$echoxsdFilename}"><xsl:value-of select="$echoxsdFilename"/></a></li>
	    <li><a href="{$wsdlFilename}"><xsl:value-of select="$wsdlFilename"/></a></li>
	    <li><a href="{$wsdl20Filename}"><xsl:value-of select="$wsdl20Filename"/></a></li>
	</ul>

	<p>The following valid instance documents are provided:</p>
	<table border="1" width="100%">
	    <tr><th>Instance</th><th>Validity</th></tr>

	    <xsl:for-each select="//ex:example[@xml:id=$exampleId]">
		<xsl:for-each select="ex:instance">
		    <xsl:variable name="instanceId" select="./@xml:id"/>
		    <xsl:variable name="result" select="$validation-results/result[@instance=$instanceId]"/>
		  <tr>
		    <td><a href="#{$instanceId}"><xsl:value-of select="$instanceId"/></a></td>
		    <td>
			<xsl:choose>
			   <xsl:when test="$result/@success = 'true'">
				<xsl:attribute name="bgcolor">#88FF88</xsl:attribute>
				true
			   </xsl:when>
			   <xsl:otherwise>
				<xsl:attribute name="bgcolor">#FF8888</xsl:attribute>
				<code><xsl:value-of select="$result"/></code>
			   </xsl:otherwise>
			</xsl:choose>
		    </td>
		  </tr>
		</xsl:for-each>
	    </xsl:for-each>
        </table>
	<p/>
	    <xsl:for-each select="ex:instance">
	    <xsl:variable name="instanceId" select="./@xml:id"/>
	    <a name="{@xml:id}"></a>
	    <div class="exampleInner">
		<pre><xsl:attribute name="xml:space">preserve</xsl:attribute><xsl:apply-templates select="./*" mode="pre"/></pre>
<!--
	    <xsl:call-template name="annotate-xml">
		<xsl:with-param name="document" select="./*"/>
		<xsl:with-param name="opts"><opts xmlns="" namespaces="0"/></xsl:with-param>
		<xsl:with-param name="patterns"><detected/></xsl:with-param>
	    </xsl:call-template>
-->
	    </div>

	    <ul>
		<li><a href="{$exampleId}-{@xml:id}.xml"><xsl:value-of select="concat($exampleId, '-', @xml:id, '.xml')"/></a></li>
		<li><a href="echo{$exampleId}-{@xml:id}.xml"><xsl:value-of select="concat('echo', $exampleId, '-', @xml:id, '.xml')"/></a></li>
		<li><a href="echo{$exampleId}-{@xml:id}-soap11.xml"><xsl:value-of select="concat('echo', $exampleId, '-', @xml:id, '-soap11.xml')"/></a></li>
		<li><a href="echo{$exampleId}-{@xml:id}-soap12.xml"><xsl:value-of select="concat('echo', $exampleId, '-', @xml:id, '-soap12.xml')"/></a></li>
	    </ul>

	    </xsl:for-each>


<!--
    <p>This is an example
	<rddl:resource id="XMLSchemaSpec" 
	    xlink:title="XML Schema 1.0 specification" 
	    xlink:role="http://www.isi.edu/in-notes/iana/assignments/media-types/text/html" 
	    xlink:arcrole="http://www.rddl.org/purposes#normative-reference" 
	    xlink:href="http://www.w3.org/TR/2006/CR-wsdl20-20060327/"
	    xlink:type="simple"
	    xlink:show="none"
	    xlink:actuate="none">

	    <a href="http://www.w3.org/TR/2006/CR-wsdl20-20060327/">Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language</a>
	</rddl:resource> 2006-03-27 specification.</p>
-->

    <hr/>
	<xsl:copy-of select="document('address.xml')/suffix/*"/>
	<p>Generated from <a href="examples.xml">examples.xml</a> &#x24;Date$</p>
  </body>
</html>
        </xsl:result-document>        
    </xsl:template>

    <xsl:template match="*" mode="pre">
        <xsl:text>&#10;</xsl:text>
        <xsl:call-template name="xml-to-string">
            <xsl:with-param name="include-ns-decls" select="false()"/>
        </xsl:call-template>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

</xsl:stylesheet>
