﻿<?xml version="1.0" encoding="UTF-8"?>
<!-- We must define several namespaces, because we need them to access -->
<!-- the document model of the in-memory OpenOffice.org document.  -->
<!-- If we want to access more parts of the document model, we must-->
<!-- add there namesspaces here, too.  -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
   xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
   xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
   exclude-result-prefixes="office table text">
<xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no"/>
<!-- By setting the PropertyValue "URL" in the properties used in storeToURL(), -->
<!-- we can pass a single parameter to this stylesheet. -->
<!-- Caveat: If we use the "URL" property in the stylesheet and call in OOo -->
<!-- from the menu "File" > "Export...", OOo assigns a target URL. And that -->
<!-- might not be what we want. -->
<xsl:param name="targetURL"/>
<!-- Process the document model -->
<xsl:template match="/">
   <boso-medicus>
      <patient>
         <!-- Process all tables -->
         <xsl:apply-templates select="//table:table"/>
      </patient>
   </boso-medicus>
</xsl:template>
<xsl:template match="table:table">
   <xsl:for-each select="table:table-row">
      <xsl:if test="position()=2">
         <xsl:for-each select="table:table-cell">
            <xsl:choose>
               <xsl:when test="position()=1">
                  <pa_no><xsl:value-of select="text:p"/></pa_no>

               </xsl:when>
               <xsl:when test="position()=2">
                  <pa_name><xsl:value-of select="text:p"/></pa_name>

               </xsl:when>
               <xsl:when test="position()=3">
                  <pa_prename><xsl:value-of select="text:p"/></pa_prename>

               </xsl:when>
               <xsl:when test="position()=4">
                  <pa_gender><xsl:value-of select="text:p"/></pa_gender>
               </xsl:when>
               <xsl:when test="position()=5">
                  <pa_birthday><xsl:value-of select="text:p"/></pa_birthday>

               </xsl:when>
               <xsl:when test="position()=6">
                  <pa_insurance_no><xsl:value-of select="text:p"/></pa_insurance_no>

               </xsl:when>
               <xsl:when test="position()=7">
                  <pa_size><xsl:value-of select="text:p"/></pa_size>
               </xsl:when>
               <xsl:when test="position()=8">
                  <pa_weight><xsl:value-of select="text:p"/></pa_weight>

               </xsl:when>
               <xsl:when test="position()=9">
                  <pa_street><xsl:value-of select="text:p"/></pa_street>

               </xsl:when>
               <xsl:when test="position()=10">
                  <pa_zip><xsl:value-of select="text:p"/></pa_zip>

               </xsl:when>
               <xsl:when test="position()=11">
                  <pa_city><xsl:value-of select="text:p"/></pa_city>
               </xsl:when>
               <xsl:when test="position()=12">
                  <pa_remarks xml:space="preserve"><xsl:value-of select="text:p"/></pa_remarks>

               </xsl:when>
            </xsl:choose>
         </xsl:for-each>
      </xsl:if>
   </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
