[XML Filter] Create XSLT filters for import and export

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
fai
Posts: 1
Joined: Sun Jan 12, 2014 8:20 pm

Re: [XML Filter] Create XSLT filters for import and export

Post by fai »

Captain Jack wrote: This was the answer.
My filter was installed under: /Volumes/temp/xml-export.xml
/Volumes/temp is a mounted networkfolder.

For me everything was OK because OO let me choose the file from my harddisk and
that was exactly what I did.
And the script worked - at least a part of it.

If I install it with your JAR File the filter goes to
/Users/xxxmynamexxx/Library/Application Support/OpenOffice.org/3/user/xslt/xml-export/xml-export.xml
That seems to be the right place - at leat on the Mac.

Thanks again for your help.
I had the same problem as Caption Jack and solved it by copying the export filter file from a mounted folder to Desktop. Then LibreOffice used it correctly to export.
LibreOffice 3.5.7.2 on Ubuntu 12.04 LTS
lapa
Posts: 1
Joined: Wed Jan 29, 2014 12:52 am

Re: [XML Filter] Create XSLT filters for import and export

Post by lapa »

Hi folks,

I have a problem with XSLT filters since upgraded to 4.0.1. On both Windows 8.1 and Windows 7 while exporting file to text format, in result i get empty file. On 3.4.1 everything was working fine, but on 4.0.1 it's not. I can't downgrade to 3.4.1 because on 8.1 it causes explorer.exe freezes...
OpenOffice 4.0.1 on Windows 8.1
sam77
Posts: 1
Joined: Wed Jun 25, 2014 11:57 am

Re: [XML Filter] Create XSLT filters for import and export

Post by sam77 »

Hi,

I am trying to export an ods file to xml. Everything works fine with the XSLT provided earlier in this post except that if we have mutiple lines in one cell, then only the first line is getting exported to XML. Eg: Lets say I have a table like below:

ColumnA ColumnB
TestRow1 TestCOlBLine1
TestCOlBLine2
TestRow2 TestCOlBLine3
TestCOlBLine4

Only TestCOlBLine1 and TestCOlBLine3 values are captured in the xml.

Below is the code from XSLT:
<xsl:when test="position()=5">
<custom_field>
<name>Actor</name>
<value><xsl:value-of select="text:p"/></value>
</custom_field>
</xsl:when>

Appreciate any help in this regard.
OpenOffice 4 on Windows 7
sushidelic
Posts: 4
Joined: Thu Jun 25, 2015 11:20 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by sushidelic »

hol.sten wrote:
giorg wrote:Now my question. I have a little more complex xml, like this:
I expanded your example to this:

Code: Select all

<?xml version="1.0"?>
<certlist>
  <cert>
    <prop1>cert1 prop1</prop1>
    <prop2>cert1 prop2</prop2>
    <achne>
      <prop3>cert1 prop3 of achne</prop3>
      <prop4>cert1 prop4 of achne</prop4>
    </achne>
    <prop5>cert1 prop5</prop5>
  </cert>
  <cert>
    <prop1>cert2 prop1</prop1>
    <prop2>cert2 prop2</prop2>
    <achne>
      <prop3>cert2 prop3 of achne</prop3>
      <prop4>cert2 prop4 of achne</prop4>
    </achne>
    <prop5>cert2 prop5</prop5>
  </cert>
  <cert>
    <prop1>cert3 prop1</prop1>
    <prop2>cert3 prop2</prop2>
    <achne>
      <prop3>cert3 prop3 of achne</prop3>
      <prop4>cert3 prop4 of achne</prop4>
    </achne>
    <prop5>cert3 prop5</prop5>
  </cert>
</certlist>
creates a spreadsheet like this:

Code: Select all

+--------------+---------------+------------------------+------------------------+--------------+
I prop1        I  prop2        I  achne/prop3           I  achne/prop4           I  prop5       I
+--------------+---------------+------------------------+------------------------+--------------+
I cert1 prop1  I  cert1 prop2  I  cert1 prop3 of achne  I  cert1 prop4 of achne  I  cert1 prop5 I
+--------------+---------------+------------------------+------------------------+--------------+
I cert2 prop1  I  cert2 prop2  I  cert2 prop3 of achne  I  cert2 prop4 of achne  I  cert2 prop5 I
+--------------+---------------+------------------------+------------------------+--------------+
I cert3 prop1  I  cert3 prop2  I  cert3 prop3 of achne  I  cert3 prop4 of achne  I  cert3 prop5 I
+--------------+---------------+------------------------+------------------------+--------------+
Hello,
can anyone help me ;)
how can i export this structure from OO to the example XML? :)
OpenOffice 4.1.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by Villeroy »

sushidelic wrote: Hello,
can anyone help me ;)
how can i export this structure from OO to the example XML? :)
That would be the purpose of an EXport filter as introduced in the first posting of this topic.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
sushidelic
Posts: 4
Joined: Thu Jun 25, 2015 11:20 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by sushidelic »

I have read this, but i have problem with the <achne></achne> Block in <cert> Block. (And no example found.)
Sorry my english are very bad ;)

Deutsch: ich habe Probleme mit der Verschachtelung in den xmls, da einen sauberen Export hinzubekommen. Wenn jemand für sowas vielleicht mal ein Beispiel bringen könnte, wäre das sehr hilfreich. Ich habe das zumindest nicht wirklich kappiert. Danke -> Den Import der xml Daten, welche bei mir noch etwas komplexer ist als bei den beispielen hier, habe ich dank dieses Treads hinbekommen, nur klemmts halt nun noch etwas am Export.
OpenOffice 4.1.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by Villeroy »

STRENG DICH AN! Wir sind nicht hier, um Deine Arbeit zu tun (was ohne Daten ohnehin unmöglich ist).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
sushidelic
Posts: 4
Joined: Thu Jun 25, 2015 11:20 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by sushidelic »

Entschuldige, wo ist das Problem? das Bespiel von dem User mit dieser Struktur an Daten ist doch sehr gut, deswegen habe ich dieses auch direkt genommen.
Ich kann mich jetzt hinsetzen und ein Beispiel machen ja, das sieht dann wahrscheinlich so ähnlich aus wie das in dem genannten Beispiel.

Wenn ich mein Beispiel jetzt nur ummünze, wäre es , nach dir, ja dann trotzdem meine arbeit die jemand anderes macht.
Ich frage ja nicht damit mir jemand die arbeit abnimmt, sondern weil ich es nicht kappiert habe und es nicht klappt so wie ich dachte und ich auch kein beispiel dafür habe.

Ich kann aber auch gerne dafür nochmal ein Extra Beispiel erstellen, wobei ich da jetzt nicht wirklich den Sinn sehe, ausser das es mir dann noch mehr arbeit abnehmen würde, da es noch mehr auf mein beispiel angepasst wäre.

Code: Select all

<?xml ....
<db>
  <dat AttributeA="1" AttributeB="2">
    <title>
      <de>titel auf de</de>
      <en>titel auf en</en>
    </title>
    <description>
      <de>description auf de</de>
      <en>description auf en</en>
    </description>
    <daten AttributeC="XYZ" AttributeD="3" />
  </dat>
 <dat .... weitere dat blöcke>
 </dat>
</db>
Die relevanten Daten liegen alle in einer Tabelle je <dat></dat> in einer Zeile.
datAttributeA - datAttributeB - titleDe - titleEN - descriptionDE - descriptionEN - datenAttributeC - datenAttributeD

Die im Anfang erwähnten Filter und XMLs habe ja im Prinzip nur eine Ebene in den Datenblöcken und nicht mehrere? oder sehe ich da etwas falsch?

exportfilter gekürzt:

Code: Select all

<!-- Process the document model -->

<xsl:template match="/">
  <db>
   <!-- Process all tables -->
   <xsl:apply-templates select="//table:table"/>
 </db>
</xsl:template>

<xsl:template match="table:table">
  <!-- Process all table-rows after the column labels in table-row 1 -->
  <xsl:for-each select="table:table-row">
   <xsl:if test="position()>1">
   <dat>

   <!-- Process the first for columns containing purpose, amount, tax and maturity -->
     <xsl:for-each select="table:table-cell">
      <xsl:choose>

	  <xsl:when test="position()=1">
          <xsl:attribute name="AttributeA"><xsl:value-of select="text:p"/></xsl:attribute>
       </xsl:when>

       <xsl:when test="position()=2">
          <xsl:attribute name="AttributeB"><xsl:value-of select="text:p"/></xsl:attribute>
      </xsl:when>

	  <xsl:when test="position()=3">
	   <de><xsl:value-of select="text:p"/></de>
      </xsl:when>
das funktioniert so weit aber da bekomme ich das <title> nicht in die xml.
muss ich da jetzt etwas an dem <xsl:template> abändern?

das hätte ich gerne etwas näher erläutert bekommen falls sich dazu jemand erniedrigen sollte :)
~s~
Last edited by sushidelic on Thu Jun 25, 2015 5:27 pm, edited 2 times in total.
OpenOffice 4.1.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by Villeroy »

Wir wissen überhaupt nichts über Deine Probleme mit irgendwelchen Verschachtelungen. Ich stell mir vor es geht, aber keiner kriegt's hin. Da kann man halt nicht viel machen.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [XML Filter] Create XSLT filters for import and export

Post by RoryOF »

This
Filters in OpenOffice.org
gives information on how to construct and install XSLT-based filters.

I hope it is of use.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by Villeroy »

RoryOF wrote:This
Filters in OpenOffice.org
gives information on how to construct and install XSLT-based filters.

I hope it is of use.
Great source of information!
Creating the export filter is a much more difficult task. When we imported a file, a hierarchical structure like this …
<hierarchical xml structure>
… was “flattened” into a structure like this:
<flat csv structure>
The export filter will have to take this flattened structure and re-create the nesting.
Which describes the problem pretty well why it is impossible to help processing some data without knowing anything about the data.

Obviously, sushidelic knows what to do while fighting with common difficulties and gory details. This is typical for any kind of development work.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
sushidelic
Posts: 4
Joined: Thu Jun 25, 2015 11:20 am
Location: Germany

Re: [XML Filter] Create XSLT filters for import and export

Post by sushidelic »

Thx RoryOF for the Link :)
OpenOffice 4.1.1 on Windows 7
Post Reply