Hi all,
i have two problems with the oocalc xslt import/export filer. I have a
very simple xml data file. Root-element, one data per line, up-to 75
datatypes per column. Something like:
<?xml version='1.0' encoding='iso-8859-1' standalone='yes' ?>
<re>
<le>
<de1>foo first </de1>
<de3>bar </de3>
</le>
<le>
<de1> foo second</de1>
<de2> baz </de2>
</le>
<le>
<de1></de1>
<de2>also baz </de2>
</le>
</re>
My import (most things stolen!) looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:preserve-space elements="*"/>
<xsl:template match="/">
<office:document-content
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
xmlns:ooo="http://openoffice.org/2004/office"
xmlns:ooow="http://openoffice.org/2004/writer"
xmlns:oooc="http://openoffice.org/2004/calc"
xmlns:dom="http://www.w3.org/2001/xml-events"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
office:version="1.0"
>
<office:automatic-styles>
</office:automatic-styles>
<office:body>
<office:spreadsheet>
<table:table>
<table:table-row>
<table:table-cell><text:p>DE1</text:p></table:table-cell>
<table:table-cell><text:p>DE2</text:p></table:table-cell>
<table:table-cell><text:p>DE3</text:p></table:table-cell>
</table:table-row>
<xsl:for-each select="re/le">
<table:table-row>
<table:table-cell><text:p><xsl:value-of
select="de1"/></text:p></table:table-cell>
<table:table-cell><text:p><xsl:value-of
select="de2"/></text:p></table:table-cell>
<table:table-cell><text:p><xsl:value-of
select="de3"/></text:p></table:table-cell>
</table:table-row>
</xsl:for-each>
</table:table>
</office:spreadsheet>
</office:body>
</office:document-content>
</xsl:template>
</xsl:stylesheet>
And my export (also stolen!) looks like:
<?xml version="1.0" encoding="iso-8859-1"?>
<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='iso-8859-1'
standalone="yes" omit-xml-declaration = "no"/>
<xsl:preserve-space elements="text:p" />
<xsl:template match="/">
<re'>
<xsl:apply-templates select="//table:table"/>
</re>
</xsl:template>
<xsl:template match="table:table">
<xsl:for-each select="table:table-row">
<xsl:if test="position()>1">
<le>
<xsl:for-each select="table:table-cell">
<xsl:variable name="pos" select="position() +
sum(preceding-sibling::*/@table:number-columns-repeated) -
count(preceding-sibling::*/@table:number-columns-repeated)"/>
<xsl:variable name="val"><xsl:value-of select="text:p"/></xsl:variable>
<xsl:if test="$pos<=75 and $val!=''">
<xsl:choose>
<xsl:when test="$pos=1"><de1><xsl:value-of
select="$val"/></de1></xsl:when>
<xsl:when test="$pos=2"><de2><xsl:value-of
select="$val"/></de2></xsl:when>
<xsl:when test="$pos=3"><de3><xsl:value-of
select="$val"/></de3></xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</le>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If i use:
cat data.xml | xalan -xsl import.xsl | xalan -xsl export.xsl > data.out.xml
everything is fine! I loose the empty de1-tag in the third le, but i
get all spaces and an encoding of iso-8859-1.
If i install the filters in oocalc (2.4.1/Linux), open the data.xml
and save it again, the encoding is set to UTF-8 and all spaces are
shortet as it's done by normalize-space()!
Any hints???
Thank's and sorry for my broken english, my ugly stolen code and the
crosspost if someone get's the [EMAIL PROTECTED] mails!
Sometimes i'm simply stupid!
Regards,
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]