I am trying to run a Java code, that is related to converting xml to csv. The use of an xsl file is necessary. However, some problems seem to exist in the code, because when running the Java code I am receiving an empty csv file (with only title of each column present). The Java code works really fine, because I used it with some test data.
So the problem is reggarding the xsl file.
My xml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<fcd-export xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/fcd_file.xsd">
<data time="0.00">
<mobil id="1" x="23.774532" y="37.967331" angle="229.707852" type="car" speed="0.000000" pos="5.100000" lane="32041497_0" slope="0.000000"/>
<mobil id="2" x="23.758638" y="37.971738" angle="38.291786" type="car" speed="0.000000" pos="5.100000" lane="265887574#0_0" slope="0.000000"/>
</data>
<data time="1.00">
<mobil id="1" x="23.774522" y="37.967326" angle="230.554332" type="car" speed="1.000000" pos="6.100000" lane="32041497_0" slope="0.000000"/>
<mobil id="2" x="23.758645" y="37.971745" angle="38.291786" type="car" speed="1.000000" pos="6.100000" lane="265887574#0_0" slope="0.000000"/>
</data>
<data time="2.00">
<mobil id="1" x="23.774503" y="37.967316" angle="233.076683" type="car" speed="2.000000" pos="8.100000" lane="32041497_0" slope="0.000000"/>
<mobil id="2" x="23.758660" y="37.971759" angle="38.291786" type="car" speed="2.000000" pos="8.100000" lane="265887574#0_0" slope="0.000000"/>
</data>
While my xsl file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" >
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
x
<xsl:for-each select="/data">
<xsl:value-of select="/data/mobil/@x" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
What I want is to declare in lines 5-7 that I want the values of the attribute: x of mobil etiquette.
fcd-export. 2. Iffcd-exportis the root element, then your XSLT will not do anything, because it assumesdatais the root element.