|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
||||
|
||||
|
NEW to xml, not binding in an html page. Apache?
Hi all,
I am a complete XML NEWBIE, so please bear with me if these questions are dumb. ![]() I just wrote my very first xml file ever. I am making a list of all of my mp3's so I can post them on my site. I think I binded it to the html properly, but perhaps not because when I go to the site, all I get is a small box. Here's the url: http://www.bartlett-family.net/chris/hobbies/ I attached the xml document, and have provided the html code here. Code:
<html> <body> <xml id="cdcat" src="music.xml"></xml> <table border="1" datasrc="#cdcat"> <tr> <td><span datafld="ARTIST"></span></td> <td><span datafld="TITLE"></span></td> </tr> </table> </body> </html> Both of these files (the html and xml files) are in the same server directory. Is there something I need to do to may Apache server to permit xml documents, or is the server irrelevant completely? Again, I'm a xml newbie! Thanks, fellas!
__________________
Pop, pop, fizz, fizz, oh what a relief it is! |
|
#2
|
||||
|
||||
|
NM, I figured it out!
Chris |
|
#3
|
|||
|
|||
|
Hello cjwsb. You weren't too far off in your guess about "not binding the file to the xml"... Since you are a newbie, perhaps you don't understand that if you want to view your XML data, you should really do it as an XSL transformation. You probably have no clue what that is, so visit http://www.w3schools.com/xsl for more info.
In short, an XSL tranformation is a way to view your XML file through the use of HTML. So you write your xml file, and link it to the XSL by putting something like this at the top of your xml file, after the XML declaration: <?xml-stylesheet type="text/xsl" href="music.xsl" ?>. The music.xsl file is the file that contains the information on transforming the XML document. Again to clarify, you're not viewing your XSL document or an HTML document, rather you're viewing the XML document and the transformation is happening automatically. (You can do client side or server side transformations, but let's not get into that right now.) I created two implementations of the XSL code, with the latter being my prefered method, as I believe it allows for greater versitility in the future, (say you want to arrange them alphabetically, etc). If I wanted to take your html code and make it an XSL, it would look like this: music.xsl 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>
<head>
</head>
<body>
<xml id="cdcat" src="music.xml"></xml>
<table border="1" datasrc="#cdcat">
<tr>
<td><span datafld="ARTIST"></span></td>
<td><span datafld="TITLE"></span></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
If you are new to XML and XSL though, this is rather confusing, and is not very standard to what W3 Schools recommends for transformations. So here is my version of the XSL. music.xsl 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>
<head>
<!-- You can do the CDATA as you had it, but that is
rather complicated. This is a more standard XSL
transformation. Visit http://www.w3schools.com/xsl
to learn more about XSL and XML. -->
</head>
<body>
<table border="1">
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="ARTIST" /></td>
<td><xsl:value-of select="TITLE" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
And here is a truncated XML file just to clear up any potential confusion, notice the link to musix.xsl: music.xml Code:
<?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="music.xsl" ?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> </CATALOG> |
|
#4
|
||||
|
||||
|
Thanks for the reply, tsprings!
I am learning more and more. I did get it working, man. Thanks for the tips! Chris Last edited by cjwsb : November 26th, 2003 at 01:52 PM. |
|
#5
|
||||
|
||||
|
Hi again, guys...
I "finished" setting up my xml list at http://www.bartlett-family.net/chris/hobbies Other than having laughable, archaic code (let's keep the laughter to a minimum, I'm not going for a gold star here ), I am pleased with how it looks.The only other thing I would like to do is to actually have the song TITLES be links that go to the mp3 file itself. Where would I place the anchor? In the xml somehow? In the html somehow? How do I do this? Thanks! Chris |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > NEW to xml, not binding in an html page. Apache? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|