<?xml version="1.0" encoding="utf-8" ?>
<!-- OpenOffice.Org transformation to WikiSyntax by Brad Dixon (MontaVista Software) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                                   xmlns:office="http://openoffice.org/2000/office" 
                                                  xmlns:style="http://openoffice.org/2000/style"
                                                  xmlns:text="http://openoffice.org/2000/text" 
                                                 xmlns:table="http://openoffice.org/2000/table"
                                                 xmlns:draw="http://openoffice.org/2000/drawing"
                                                 xmlns:fo="http://www.w3.org/1999/XSL/Format "
                                                xmlns:xlink="http://www.w3.org/1999/xlink"
                                                xmlns:number="http://openoffice.org/2000/datastyle"
                                               xmlns:svg="http://www.w3.org/2000/svg"
                                               xmlns:chart="http://openoffice.org/2000/chart"
                                               xmlns:dr3d="http://openoffice.org/2000/dr3d"
                                               xmlns:math="http://www.w3.org/1998/Math/MathML"
                                               xmlns:form="http://openoffice.org/2000/form"
			 xmlns:html="http://www.w3.org/1999/xhtml"
			      xmlns:scripts ="http://architag.com/scripts" 
			            xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                                               xmlns:script="http://openoffice.org/2000/script">
	<xsl:output method="html"/>
<xsl:param name="mainstream" select='office:*'/>

  <xsl:include href="..\XslWiki\wiki.xsl" /> 
<xsl:template name="two-for-wiki">
<xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="/">
    <xsl:param name="mainstream" select='office:*'/>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
   
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 2007 08:21:57 GMT"/>

        <style>
          .title { float:left; text-align:center; border:1px solid black; margin: 1em; padding: 1em; width: 12em; background-color:#eee } 
          .title p { text-align:center }
        </style>
  <script type="text/jscript">
	<xsl:comment>
		<![CDATA[
			var seq = 1;
			var exp = null;
			var ys = 0.0;
	 		
			function moveText(t)
			{try {	var e; var p; var r;
				var oldValue = document.getElementById("old");
				var newValue =  document.getElementById("new");
				var wikiSource =  document.getElementById("hiddenSource");
				newValue.value = oldValue.value;
				window.status="XslWiki loaded";								                  wikiSource.style.display = "none";
			     }catch(exception) { window.status="XslWiki error:"+exception.description }
			}
				function ESC_KeyDown()
							{
								//window.status= event.keyCode ;
								if( 27 == event.keyCode )
								{
									self.close();
								}
							}

						]]>
					</xsl:comment>
				</script>
 <xsl:call-template name="get-wiki-head"><xsl:with-param name="title" select="."/></xsl:call-template>

      </head>
      <body>  <xsl:attribute name="onload">moveText(this)</xsl:attribute>
         <a name="PageTop"></a>
         <xsl:call-template name="get-wiki"><xsl:with-param name="title" select="."/>
      </xsl:call-template>
        <xsl:apply-templates/>
 <!-- End of page
-->
        <a name="PageBottom"></a>
      </body>
    </html>
  </xsl:template>
 <msxsl:script implements-prefix="scripts" > 

   <![CDATA[ 
      var WikiNameRegexp = "/(?<![A-Za-z0-9])([A-Z][a-z]+){2,}(?![A-Za-z0-9])";
      var g_obj = new Array();
      var parts;
      var seqTextArea = 0;
             function tget(p){ 
             return parts[p];
}
          function tname(ctx){ 
          var tmp;
	seqTextArea++;
           if(seqTextArea == 1) return "old";
           return "new";
}
          function findTopics(ctx){ 
          var tmp;
          var tmp2;
         // var idVal = ctx.getAttribute("id");

          var replaceText = ctx.nextNode().text;
         replaceText = replaceText.replace(WikiNameRegexp, '%ICON{"xml"}% ');
var tdom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");// THIS LINE MAKE CODE IE DEPENDANT
           var od = tdom.createNode(1, 'myRE', '');
              parts = replaceText.split('---++++++');
	if (parts  != null){
		//
		for (var i=1; i < parts.length; i++){
			//window.status =window.status + parts[i];
			tmp=parts[i].split('/n');

			var mn = tdom.createNode(1, 'h2', '');
			var tn = tdom.createTextNode(tmp[1]);
			mn = od.appendChild(mn);
			tn = mn.appendChild(tn);
			mn = tdom.createNode(1, 'h1', '');
			var tn = tdom.createTextNode(tmp[0]);
			mn = od.appendChild(mn);
			tn = mn.appendChild(tn);
			g_obj[i] = tmp[0];
		}
		//
    for (var i=1; i < g_obj.length; i++){
	//window.status =window.status + parts[i];
	tmp2=tmp2 + ' ' +g_obj[i]; 

           }
                                     mn = tdom.createNode(1, 'h1', '');
		var tn = tdom.createTextNode(tmp2);
		mn = od.appendChild(mn);
		tn = mn.appendChild(tn);
		
		return od.selectNodes("*");
	}
}
function topicGroup(ctx){ 
          var tmp='';
          var st='';
          var replaceText = ctx.nextNode().text;
         replaceText = replaceText.replace(WikiNameRegexp, '%ICON{"xml"}% ');
          for (var i=1; i < g_obj.length; i++){
	//window.status =window.status + parts[i];
	tmp=tmp + ' ' +g_obj[i]; 

           }
           tmp = tmp.replace('/n ', ' ');
           tmp = tmp.replace('/n ', ' ');
      tmp = tmp.replace('          ', ' ');
           tmp = tmp.replace('    ', ' ');
           tmp = tmp.replace('     ', ' ');
           tmp = tmp.replace('  ', ' ');
           return tmp;
}

 
function   _wander(ctx){
	var retStr = "";
	for (var i=0; i < ctx.childNodes.length; i++){
		ctxN = ctx.childNodes[i];
		switch(ctxN.nodeType){
			case 1:
				retStr +=   _wander(ctxN);
				break;
			case 3:
				retStr += ctxN.nodeValue;
				break;
			default:
				break;
		}
	}
	return retStr;
}
    function showXML(nodelist)
           {
           txtResult = "<SPAN "+
               "STYLE='background-color:lightyellow;" +
               "cursor:hand;font-size:8pt;' " +
               "TITLE='"
           replaceText = nodelist.nextNode().xml
           replaceText = replaceText.replace(/&/g, '&amp;')
           replaceText = replaceText.replace(/</g, '&lt;')
           replaceText = replaceText.replace(/>/g, '&gt;')
           replaceText = replaceText.replace(/'/g, '&rsquo;')
           txtResult += replaceText
           txtResult += "'>(show xml)</SPAN>"
           return txtResult;
           }
  function findItems(nodelist)
           {
        
           var replaceText = nodelist.nextNode().xml;
            replaceText = replaceText.replace(WikiNameRegexp, '%ICON{"xsl"}% ');
           replaceText = replaceText.replace(/ ---/g, '%ICON{"xml"}% ');
     
         
           return replaceText;
           }


  ]]> 

</msxsl:script>
  <xsl:template match="html:textarea">
                       <xsl:variable name="textAreaId" select="scripts:tname(.)"/>

	     <xsl:element name="textarea"><!--NEED TO TEST FOR CORRECT TEXT AREA-->
		<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> 
		<xsl:attribute name="wrap"><xsl:value-of select="@wrap"/></xsl:attribute> 
                                    <xsl:attribute name="rows">20</xsl:attribute>
 		<xsl:attribute name="cols">70</xsl:attribute>
		<xsl:attribute name="id"><xsl:value-of select="$textAreaId"/></xsl:attribute>
                                    <xsl:attribute name="onload">moveText(this)</xsl:attribute>
		
 <!-- 
  		       <xsl:call-template name="two-for-wiki">
        		                         <xsl:with-param name="search-term" select="scripts:topicGroup(.)"/>
                                           </xsl:call-template>
		
                       <xsl:value-of select="scripts:showXML(.)"/>  -->
                        <xsl:apply-templates select ="$mainstream" />
 
                       </xsl:element>
	    
  </xsl:template>
	<!-- Catch the non-content document sections -->
	<xsl:template match="/XML"/>
	<xsl:template match="/office:document/office:meta"/>
	<xsl:template match="/office:document/office:settings"/>
	<xsl:template match="/office:document/office:document-styles"/>
	<xsl:template match="/office:document/office:font-decls"/>
	<xsl:template match="/office:document/office:styles"/>
	<xsl:template match="/office:document/office:master-styles"/>
	<!-- Formats the text sections according to the style name -->
	<xsl:template name="style-font">
		<xsl:param name="style"/>
		<!-- xsl:text>(</xsl:tex -->
		<!-- xsl:value-of select="$style"></xsl:value-of -->
		<!-- xsl:text> </xsl:text -->
		<xsl:variable name="font-style" select="//office:automatic-styles/style:style[@style:name=$style]/style:properties/@fo:font-style"/>
		<!-- xsl:value-of select="$font-style"></xsl:value-of -->
		<xsl:variable name="font-weight" select="//office:automatic-styles/style:style[@style:name=$style]/style:properties/@fo:font-weight"/>
		<!-- xsl:value-of select="$font-weight"></xsl:value-of -->
		<xsl:variable name="font-underline" select="//office:automatic-styles/style:style[@style:name=$style]/style:properties/@style:text-underline"/>
		<!-- xsl:value-of select="$font-underline"></xsl:value-of -->
		<!-- xsl:text>)</xsl:text -->
		<xsl:choose>
			<!-- xsl:when test="not($font-weight) and not($font-style) and not($font-underline)">PLAIN</xsl:when -->
			<xsl:when test="$font-weight='bold' and $font-style='normal' and not($font-underline)">*</xsl:when>
			<xsl:when test="not($font-weight) and $font-style='italic' and not($font-underline)">_</xsl:when>
			<xsl:when test="$font-weight='normal' and $font-style='normal' and $font-underline='single'">=</xsl:when>
			<xsl:when test="$font-weight='bold' and $font-style='italic' and $font-underline='none'">__</xsl:when>
			<xsl:when test="$font-weight='normal' and $font-style='italic' and $font-underline='single'">__</xsl:when>
			<xsl:when test="$font-weight='bold' and $font-style='normal' and $font-underline='single'">__</xsl:when>
			<xsl:when test="$font-weight='bold' and $font-style='italic' and $font-underline='single'">__</xsl:when>
		</xsl:choose>
	</xsl:template>
	<!-- Text blocks -->
	<xsl:template match="//text:p">
		<xsl:variable name="cur-style-name">
			<xsl:value-of select="@text:style-name"/>
		</xsl:variable>
		<xsl:call-template name="style-font">
			<xsl:with-param name="style">
				<xsl:value-of select="$cur-style-name"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:apply-templates/>
		<xsl:call-template name="style-font">
			<xsl:with-param name="style">
				<xsl:value-of select="$cur-style-name"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<!-- List items -->
	<xsl:template match="//text:list-item">
		<xsl:text>   * </xsl:text>
		<xsl:value-of select="substring(.,1,string-length(.)-1)"/>
	</xsl:template>
	<!-- Tables -->
	<xsl:template match="//table:table">
		<xsl:variable name="table-name" select="@table:name"/>
		<xsl:text>
%EDITTABLE{name="</xsl:text>
		<xsl:value-of select="$table-name"/>
		<xsl:text>"}%</xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
	<!-- Table rows -->
	<xsl:template match="//table:table-row">
		<xsl:text>|</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<!-- Table cells in header rows -->
	<xsl:template match="//table:table-header-rows/table:table-row/table:table-cell">
		<xsl:value-of select="concat('*', substring(.,1,string-length(.)-1), '*|')"/>
	</xsl:template>
	<!-- Table cells in non-header rows -->
	<xsl:template match="//table:table/table:table-row/table:table-cell">
		<xsl:value-of select="concat(substring(.,1,string-length(.)-1),'|')"/>
	</xsl:template>
	<!-- Handles horizontally merged cells -->
	<xsl:template match="//table:covered-table-cell">
		<xsl:text>|</xsl:text>
	</xsl:template>
	<!-- Table of Contents -->
	<xsl:template match="//text:table-of-content">
		<xsl:text>
%TOC%

</xsl:text>
	</xsl:template>
	<!-- Headings -->
	<xsl:template match="//text:h[@text:level='1']">
		<xsl:text>
---+ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='2']">
		<xsl:text>
---++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='3']">
		<xsl:text>
---+++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='4']">
		<xsl:text>
---++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='5']">
		<xsl:text>
---+++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='6']">
		<xsl:text>
---++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='7']">
		<xsl:text>
---+++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='8']">
		<xsl:text>
---++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='9']">
		<xsl:text>
---+++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:h[@text:level='10']">
		<xsl:text>
---++++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 1']">
		<xsl:text>
---+ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 2']">
		<xsl:text>
---++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 3']">
		<xsl:text>
---+++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 4']">
		<xsl:text>
---++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 5']">
		<xsl:text>
---+++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 6']">
		<xsl:text>
---++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 7']">
		<xsl:text>
---+++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 8']">
		<xsl:text>
---++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 9']">
		<xsl:text>
---+++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
	<xsl:template match="//text:p[@text:style-name='Heading 10']">
		<xsl:text>
---++++++++++ </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>
</xsl:text>
	</xsl:template>
</xsl:stylesheet>

