|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Hi people.
I'm new to the whole XML/XSL lark, coming from a HTML/PHP/MySQL background. I'm having fun creating an application that currently uses IE's built-in parsing engine, but i've hit a problem. How do I translate an attribute from XML to HTML? Such as the following... Code:
<!-- xml file -->
<?xml version="1.0"?>
<base>
<item id="1" />
<item id="2" />
<!-- etc -->
</base>
<!-- xsl file -->
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="item">
<ul>
<li id="<xsl:value-of select="@id" />"><xsl:value-of select="@id" />
</ul>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I'm sure someone's come across this before, but none of the tutorials i've come across have mentioned anything to do with this.
__________________
R.T.F.M - Its the only way to fly... "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds." Personal: experience// 8 Years Web Development technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs packages// Photoshop, Illustrator, Flash/Fireworks/Director environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi site// //refactored.net/ (Coming soon...) quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning... |
|
#2
|
||||
|
||||
|
Try the following:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="yes"/><xsl:template match="/"> <HTML> <BODY> <xsl:for-each select="base/item"> <ul> <li id="{@id}"/><xsl:value-of select="@id"/> </ul> </xsl:for-each> </BODY> </HTML> </xsl:template> </xsl:stylesheet> |
|
#3
|
||||
|
||||
|
Sorry ...
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="yes"/>
<xsl:template match="/">
<HTML>
<BODY>
<xsl:for-each select="base/item">
<ul>
<li id="{@id}"/><xsl:value-of select="@id"/>
</ul>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
|
|
#4
|
||||
|
||||
|
Thanks for your help. Works great with attributes. And works with Javascript.
Bonus! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML > HTML, outputting into quotes? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|