How can I properly convert xhtml to csv?



I'm having trouble transforming a xhtml file to a csv using xslt. The xhtml file looks like this:



<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://ift.tt/lH0Osb">
<head>
<title>Flight details</title>
</head>
<body>
<h1>Flight details</h1>
<ul>
<li id="nam">BLA145</li>
<li id="reg">YK-LOL</li>
<li id="hex">000100</li>
<li id="alt">34950</li>
<li id="spd">457</li>
<li id="hdg">117</li>
<li id="sqk">4774</li>
</ul>
</body>
</html>


The stylesheet is as follows:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR"
xmlns:xhtml="http://ift.tt/lH0Osb"
exclude-result-prefixes="xhtml xsl">

<xsl:output method="text" encoding="UTF-8"/>

<xsl:template match="/">
<xsl:apply-templates select="html/body/ul/*"/>
</xsl:template>
<xsl:template match="li[@id='nam']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='reg']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='hex']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='alt']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='spd']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='hdg']">
<xsl:value-of select="."/>,
</xsl:template>
<xsl:template match="li[@id='sqk']">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>


This will result in no output. I've observed that if I remove



xmlns="http://ift.tt/lH0Osb"


from the <html > tag, then the csv will be generated correctly.


Is this a namespace problem? How could I solve it?


Thank you!


No comments:

Post a Comment