How each table separately in XSLT filter ?

Here should go questions about transforming XML with XSLT and FOP.
quotsi
Posts: 1

How each table separately in XSLT filter ?

Mon May 14, 2018 8:29 pm

I am writing/testing a short XSLT export filter transforming a OpenOffice calc file return to a XML file for reimport to "boso profile manager XD".
The calc file has 3 (or more) tables, first or patients name etc., the further for each date-time intervall with the values.
My filter program is not complete and correct. I can not separate the tables so that I can not distinguish between patient name etc. and the values.
How can I separate the tables?
Thanks for help.
quotsi

My XSLT filter:
]

Code: Select all

<?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">
         <Zeile>
         <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>
         </Zeile>
      </xsl:if>
   </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest