| | |
XML or XSL or What??
![]() |
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Solved Threads: 0
Hello! I am a semi-beginner in XML, and I am trying to develop a photo directorate for my company. The only problem is that I have to do everything by hand, so though I have no problem getting data from my XSL to my XML, I have not yet been able to achieve the same thing with images. Do I store the jpgs info in the XSL and transfer it? My boss is big into wanting to find out more about XSLT and use it instead of DTDs, so if anyone has further information, I am desperate for help! Also, what happens when I want to get each image from an individualized code specifically made for each image that is an Internet link? Please help! Thanks!
*I have included a rather silly example that I am just playing with to understand the coding. Below I have listed the XSL and the XML files, with the default.jpg as an image on my hard drive to attempt to get that to come up, and the .gov URL as an image to derive from the Internet. Again, thanks!
XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog p.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
<photo> default.jpg </photo>
</cd>
<cd xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
<photo>http://www.dhs.gov/threat_level/current_new.gif</photo>
</cd></catalog>
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
<th align="left">Photo</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="photo"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
*I have included a rather silly example that I am just playing with to understand the coding. Below I have listed the XSL and the XML files, with the default.jpg as an image on my hard drive to attempt to get that to come up, and the .gov URL as an image to derive from the Internet. Again, thanks!
XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog p.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
<photo> default.jpg </photo>
</cd>
<cd xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
<photo>http://www.dhs.gov/threat_level/current_new.gif</photo>
</cd></catalog>
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
<th align="left">Photo</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="photo"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Last edited by JulieMHill; Jul 13th, 2007 at 1:04 pm.
"only problem is that I have to do everything by hand"
That's no problem at all, unless your hand is broken (and if so you can learn to use your other hand).
First you should try to figure out what the heck you're trying to do, because you certainly don't explain it here.
After that you should figure out what XSLT actually is as you seem to think it's some kind of magic bullet that just does everything all the time.
That's no problem at all, unless your hand is broken (and if so you can learn to use your other hand).
First you should try to figure out what the heck you're trying to do, because you certainly don't explain it here.
After that you should figure out what XSLT actually is as you seem to think it's some kind of magic bullet that just does everything all the time.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Hello Julie,
XSL will basically be the hard-coded part to style XML. You can't assume that XSL will somehow turn image attributes into images.
So for example your line:
<td><xsl:value-of select="photo"/></td>
will have to look something like:
<td>
<img border="0">
<xsl:attribute name="src">
<xsl:value-of select="photo"/>
</xsl:attribute>
</img>
</td>
... or
<td><img border="0" src="{photo}" /></td>
What I usually do is create an HTML and then convert all that HTML including repeaters into logical XSL.
It's important to note that you want an optimum performance. Maybe, XSLT is not the best solution in some cases. Choosing between client side or server side XSLT is also an important step.
I hope that helps!
Tim
XSL will basically be the hard-coded part to style XML. You can't assume that XSL will somehow turn image attributes into images.
So for example your line:
<td><xsl:value-of select="photo"/></td>
will have to look something like:
<td>
<img border="0">
<xsl:attribute name="src">
<xsl:value-of select="photo"/>
</xsl:attribute>
</img>
</td>
... or
<td><img border="0" src="{photo}" /></td>
What I usually do is create an HTML and then convert all that HTML including repeaters into logical XSL.
It's important to note that you want an optimum performance. Maybe, XSLT is not the best solution in some cases. Choosing between client side or server side XSLT is also an important step.
I hope that helps!
Tim
hosting :: development :: design
dezignwork.com
dezignwork.com
![]() |
Similar Threads
- ASP.NET - session objects Problem (ASP.NET)
- Ignoring xmlns namespaces in the input xml file (XML, XSLT and XPATH)
- Help needed in simple app while using XML,XSL (XML, XSLT and XPATH)
- Parse XML from ASP!!! (ASP)
- xsl-fo (DaniWeb Community Feedback)
- Transforming XML with XSLT (HTML and CSS)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Linspire and Microsoft get jiggy with it
- Next Thread: Xml Validation Using DTD
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt






