G
Glen Millard
Hi;
When I reformat my XML file using xsltproc and my xsl template file, I see the following anomaly: (call it what you will!)
<?xml version="1.0" encoding="iso-8859-1"?>
<row>
<date>2012-03-04 21:16:56</date>
<src>+19095703426</src>
<dst>8774658861</dst>
<duration>24</duration>
<callerid>+19095703426</callerid>
<cost>0.0106</cost>
</row><row>
<date>2012-03-06 20:58:14</date>
<src>8883091120</src>
<dst>8885216725</dst>
<duration>24</duration>
<callerid>VFAX - Received</callerid>
<cost>0.011200000000000002</cost>
</row><row>
Notice how it does not put the <row> tag on the next line, as I would wish it to.
Here is a snippet of my original XML doc:
<?xml version="1.0" encoding="utf-8"?>
<content>
<status>ok</status>
<records>
<call>
<date>2012-03-04 21:16:56</date>
<src>+19095703426</src>
<dst>8774658861</dst>
<duration>24</duration>
<callerid>+19095703426</callerid>
<disposition>ANSWERED</disposition>
<cost>0.0106</cost>
</call>
<call>
<date>2012-03-06 20:58:14</date>
<src>8883091120</src>
<dst>8885216725</dst>
<duration>24</duration>
<callerid>VFAX - Received</callerid>
<disposition></disposition>
<cost>0.011200000000000002</cost>
</call>
<call>
..
..
..
</call>
</records>
</content>
Here is my xsl stylesheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="xml" encoding="iso-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="status"></xsl:template>
<xsl:template match="ok"></xsl:template>
<xsl:template match="/content/records/call">
<xsl:for-each select="date">
<xsl:variable name="i" select="position()"/>
<xsl:element name="row">
<xsl:element name="date">
<xsl:value-of select="."/>
</xsl:element>
<xsl:element name="src">
<xsl:value-of select="../src[$i]"/>
</xsl:element>
<xsl:element name="dst">
<xsl:value-of select="../dst[$i]"/>
</xsl:element>
<xsl:element name="duration">
<xsl:value-of select="../duration[$i]"/>
</xsl:element>
<xsl:element name="callerid">
<xsl:value-of select="../callerid[$i]"/>
</xsl:element>
<xsl:element name="cost">
<xsl:value-of select="../cost[$i]"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
What am I doing wrong? Anyone? What would be the best way to correct this please?
Thanks so much in advance for your help!
Glen
When I reformat my XML file using xsltproc and my xsl template file, I see the following anomaly: (call it what you will!)
<?xml version="1.0" encoding="iso-8859-1"?>
<row>
<date>2012-03-04 21:16:56</date>
<src>+19095703426</src>
<dst>8774658861</dst>
<duration>24</duration>
<callerid>+19095703426</callerid>
<cost>0.0106</cost>
</row><row>
<date>2012-03-06 20:58:14</date>
<src>8883091120</src>
<dst>8885216725</dst>
<duration>24</duration>
<callerid>VFAX - Received</callerid>
<cost>0.011200000000000002</cost>
</row><row>
Notice how it does not put the <row> tag on the next line, as I would wish it to.
Here is a snippet of my original XML doc:
<?xml version="1.0" encoding="utf-8"?>
<content>
<status>ok</status>
<records>
<call>
<date>2012-03-04 21:16:56</date>
<src>+19095703426</src>
<dst>8774658861</dst>
<duration>24</duration>
<callerid>+19095703426</callerid>
<disposition>ANSWERED</disposition>
<cost>0.0106</cost>
</call>
<call>
<date>2012-03-06 20:58:14</date>
<src>8883091120</src>
<dst>8885216725</dst>
<duration>24</duration>
<callerid>VFAX - Received</callerid>
<disposition></disposition>
<cost>0.011200000000000002</cost>
</call>
<call>
..
..
..
</call>
</records>
</content>
Here is my xsl stylesheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="xml" encoding="iso-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="status"></xsl:template>
<xsl:template match="ok"></xsl:template>
<xsl:template match="/content/records/call">
<xsl:for-each select="date">
<xsl:variable name="i" select="position()"/>
<xsl:element name="row">
<xsl:element name="date">
<xsl:value-of select="."/>
</xsl:element>
<xsl:element name="src">
<xsl:value-of select="../src[$i]"/>
</xsl:element>
<xsl:element name="dst">
<xsl:value-of select="../dst[$i]"/>
</xsl:element>
<xsl:element name="duration">
<xsl:value-of select="../duration[$i]"/>
</xsl:element>
<xsl:element name="callerid">
<xsl:value-of select="../callerid[$i]"/>
</xsl:element>
<xsl:element name="cost">
<xsl:value-of select="../cost[$i]"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
What am I doing wrong? Anyone? What would be the best way to correct this please?
Thanks so much in advance for your help!
Glen