XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
benjamin yapSubject: XSL problem
Author: benjamin yap
Date: 05 Mar 2006 09:10 PM
hi all,

I am new to xsl.Recently i had a problem converting xml to html.Here is the table that i wish to appear in html:

name sex code job
steven male 1 accountant
richard male 2 engineer
daniel male 3 scientist


But i just cant convert to html as what i wanted.xml code as below:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="inter2.xsl"?>
<saved>
<mo>
<attribute name="job">accountant</attribute>
<attribute name="sex">male</attribute>
<attribute name="code">1</attribute>
<attribute name="name">steven</attribute>
</mo>
<mo>
<attribute name="job">engineer</attribute>
<attribute name="sex">male</attribute>
<attribute name="code">2</attribute>
<attribute name="name">richard</attribute>
</mo>
<mo>
<attribute name="job">scientist</attribute>
<attribute name="sex">male</attribute>
<attribute name="code">3</attribute>
<attribute name="name">daniel</attribute>
</mo>
</saved>

This is my xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
<xsl:template match="saved">
<html>
<body>
<h2>FIRST TRIAL</h2>
<table border="2">
<tr bgcolor="#black">
<th align="center">job</th>
<th align="center">sex</th>
<th align="center">code</th>
<th align="center">name</th>
</tr>
<xsl:for-each select="mo/attribute">
<tr>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


Can any one help to point out my error on the xsl code?Thousand thanks

Postnext
Minollo I.Subject: XSL problem
Author: Minollo I.
Date: 06 Mar 2006 08:57 AM
You can try something like the following; BTW, this is the Stylus Studio technical support forum; if you are an XML Spy user (as the comment in your XSLT suggests), you may either consider asking for help to their support organization, or switch to Stylus Studio altogether.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with Stylus Studio 2006 Enterprise Edition -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="saved">
<html>
<body>
<h2>FIRST TRIAL</h2>
<table border="2">
<tr bgcolor="#black">
<th align="center">job</th>
<th align="center">sex</th>
<th align="center">code</th>
<th align="center">name</th>
</tr>
<xsl:for-each select="/saved/mo">
<tr>
<td>
<xsl:value-of select="attribute[@name='job']"/>
</td>
<td>
<xsl:value-of select="attribute[@name='sex']"/>
</td>
<td>
<xsl:value-of select="attribute[@name='code']"/>
</td>
<td>
<xsl:value-of select="attribute[@name='name']"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Posttop
benjamin yapSubject: XSL problem
Author: benjamin yap
Date: 06 Mar 2006 09:16 AM
dearest stylus team,

Thanks for your greatest help. I was not aware of this as somebody gave me the xml script and asked me to convert to html . I am not aware of the spy user nor stylus editor previously as i am new to xml world. But with ur greatest help/support, i will feedback to my boss to consider switch to sytlus editor in the coming purchase. Thanks alot!!

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.