I have an HTML file and i want to convert to XML only using XSLT..
I want
1.All the nodes to be retained.
2.And all elements are sorted.
3.And code should be in dynamically.
i have an huge file so i want an simple code to process all the html nodes.here i explained my codeing with the xslt
if u understand it plz help me..
My HTML file is..
<div id="2196" class="one_tail">
<span id="2197" class="one_biblio">
<span id="2198" class="one_section-title">Title</span>
<ol id="2199" class="one_biblio-sec">
<li id="2200" class="one_bib-reference">
<span id="2202" class="one_reference">
<span id="2203" class="one_contribution">
<span id="2204" class="one_authors">
<span id="2205" class="one_author">
<!--
<span id="2207" class="one_surname">Surname</span>
<span id="2206" class="one_given-name">GivenName</span>
</span>
</span>
<span id="2208" class="one_title">
<span id="2209" class="one_maintitle">technology</span>
</span>
</span>
<span id="2210" class="one_host">
<span id="2211" class="one_book">
<span id="2213" class="one_publisher">Publisher </span>
</span>
</span>.
</span>
</li>
</ol>
</span>
</div>
And i want the XML file as:
Here the attribute class value is used as element name.
<tail id="2196">
<biblio id="2197">
<section-title id="2198">Title</section-title>
<biblio-sec id="2199">
<bib-reference id="2200">
<reference id="2202">
<contribution id="2203">
<authors id="2204">
<author id="2205">
<!--
<given-name id="2206">GivenName </given-name>
<surname id="2207">Surname</surname>
</author>
</authors>
<title id="2208" >
<maintitle id="2209">technology</maintitle>
</title>
</contribution>
</reference>
<host id="2210">
<book id="2211">
<publisher id="2213">Publisher </publisher>
</book>
</host>
</bib-reference>
</biblio-sec>
</biblio>
</tail>
The XSLT i wrote is not giving what i want..
The XSLT code is:
<xsl:template match="*|/" xmlns:xsl="#unknown">
<xsl:for-each select=".">
<xsl:for-each select="current()/*">
<xsl:sort select="@id" order="ascending" />
</xsl:for-each>
<xsl:if test="starts-with(@class,'one_') ">
<xsl:variable name="nodename" select="substring-after(@class,'one_')" />
<xsl:element name="{$nodename}">
<xsl:attribute name="id" select="@id" />
<xsl:apply-templates />
</xsl:element>
</xsl:if>
<xsl:if test="not(@class)">
<xsl:apply-templates />
</xsl:if>
</xsl:for-each>
</xsl:template>
Can any one help me..