xml - Why do i get no formatted result (csv) with my xsl? -


how can give output correct format? missing in xslt? @ example below. thank in advance help.

xml:

<?xml version="1.0" encoding="utf-8"?> <fed xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">    <poi>       <id>56241</id>       <poi_contact>          <categoryid>museum</categoryid>          <name>centre pompidou</name>       </poi_contact>   </poi>    <poi>       <id>141670</id>       <poi_contact>          <categoryid>museum</categoryid>          <name>espace culturel saint-exupéry</name>       </poi_contact>    </poi>    <poi>       <id>56242</id>       <poi_contact>          <categoryid>museum</categoryid>          <name>musée du louvre</name>       </poi_contact>   </poi> </fed> 

xsl:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="text" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/">  id;category;name    <xsl:for-each select="fed/poi">          <xsl:value-of select="id"/>;     <xsl:value-of select="poi_contact/categoryid"/>   </xsl:for-each>  </xsl:template> </xsl:stylesheet> 

output:

   id;category;name    56241;     museum 141670;     museum 56242;     museum 

the output should this:

id;category;name
56241;museum
141670;museum
56242;museum

the problem specifying literal text have entire text node, including surrounding white spaces, passed output.

try instead:

<xsl:template match="/">     <xsl:text>id;category;name&#10;</xsl:text>     <xsl:for-each select="fed/poi">              <xsl:value-of select="id"/>         <xsl:text>;</xsl:text>         <xsl:value-of select="poi_contact/categoryid"/>         <xsl:text>&#10;</xsl:text>     </xsl:for-each> </xsl:template> 

p.s. header says id;category;name, not outputting name.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -