Jump to content

transform an XML file into a HTML page


sarra

Recommended Posts

Hi everyone, I try to convert an XML file to a HTML page but nothing is displayed. in the following, i put the XML code, the xslt code and the HTML page. Thank you for your help.

the XML code

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="fg.xsl" ?>

<cuimodel>
<window id='window1'>
<div>
<label id='label1'> searchPreference </label> 
<label id='label12'> seeFirst </label> 
<combobox id='CB1' name='criteriaCB'>
<item>promotions</item>
<item>BestRated </item>
</combobox>
</div>

<div>
<label id='label2'> mon </label> 
<label id='label21'> second  </label> 
<combobox id='CB2' name='DispLayout'>
<item>GridLayout</item>
<item>listlayout</item>
</combobox> 
</div>

<div>
<label id='label13'> Preference </label> 
<label id='label122'> see </label> 
<combobox id='CB3' name='CT'>
<item>HighContrast</item>
<item>LowContrast</item>
</combobox>
</div>
<button>cancel</button>
<button>ok</button>
</window>
</cuimodel>

the XSLT code

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> 
<html> 
<body> 
<xsl:for-each select="div">
<xsl:for-each select="label">
<label>
<xsl:value-of select="."/>
</label>
<select>
<xsl:for-each select="combobox">
<option>
<xsl:value-of select="item"/>
</option>
</xsl:for-each>
</select>
</xsl:for-each>
<xsl:for-each select="button">
<button>
<xsl:value-of select="."/>
</button>
</xsl:for-each> 
</xsl:for-each>
</body> 
</html>
</xsl:template>
</xsl:stylesheet>

and the HTML page 

 

tof.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...