Hi All,
I am new to this forum and I am not sure if the following question has already been raised earlier.
I have an xml file as follows:
< xml version="1.0" encoding="UTF-8" >
< xml:stylesheet href="styles.xsl" type="text/xsl" >
<collection>
<book>
<index>1</index>
<author year= "1990" > John Doe </author>
<title> JavaScript </title>
<price> 10.99 </price>
</book>
<book>
<index>2</index>
<author year= "2000" > Mary Jones </author>
<title> Photoshop Secrets </title>
<price> 15.99 </price>
</book>
<book>
<index>3</index>
<author year= "2005" > Garry Po </author>
<title> PHP Programming </title>
<price> 20.99 </price>
</book>
<book>
<index>4</index>
<author year= "2005" > Garry Po </author>
<title> PHP Programming </title>
<price> 20.99 </price>
</book>
</collection>
And the corresponding xsl file is as follows:
< xml version="1.0" >
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<!-- / forward slash is used to denote a patern that matches the root node of the XML document -->
<xsl:template match ="/" >
<html>
<head>
<title> Book Collection </title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="collection" >
<table width="400" border="1" >
<tr bgcolor = "#cccccc" >
<td>Index</td>
<td>Author</td>
<td>Year</td>
<td>Name</td>
<td>Price</td>
</tr>
<xsl:for-each select="book" >
<xsl:variable name="index_anchor">
<xsl:value-of select="index" />
</xsl:variable>
<tr>
<td id="{$index_anchor}"> <xsl:value-of select="index" /> </td>
<td> <xsl:value-of select="author" /> </td>
<!-- here we use /@ to access the value of an attribute -->
<td> <xsl:value-of select="author/@year" /> </td>
<td> <xsl:value-of select="title" /> </td>
<td> <xsl:value-of select="price" /> </td>
</tr>
</xsl:for-each>
</table>
</xsl:template >
</xsl:stylesheet >
The strange problem that I am facing is:
When
I have these two files on the desktop, the tags work perfectly fine.
For instance c:\documents and settings\neelima\desktop\books.xml#2
But when I have the same files in another directory/folder on the desktop, there seems to be a problem.
NOTE: Make an xml file say books.xml and also an xsl
file say styles.xsl...now copy these two files onto your desktop. When
you try to open the xml file in IE6, it works fine. It also works when
you give in the address bar as
c:\...Desktop\books.xml#12
Make
a folder by name Work on your desktop. Now copy the two files into this
folder. And when you try to open the xml file in IE6, it shows up
properly with out any errors. But when I try giving the following in
the address bar
c:\...Desktop\Work\books.xml#12
I am getting the following error:
"Windows cannot find 'c:\...\Desktop\Work\books.xml#12'. Check the spelling and try again, or try searching for the item by clicking the Start button and then clicking Search."
NOTE: Please try with the tags...#12, etc. Otherwise it works fine.
Can some one please tell me what could be the problem
Thanks,
Neelima

XML view in IE
Tim Allen
Hello again,
Did some testing and I think what your doing isn't working because your not generating any named anchors in the html.
<tr>
<td id="{$index_anchor}"> <a name="{$index_anchor}"/><xsl:value-of select="index" /> </td>
<td> <xsl:value-of select="author" /> </td>
if you add the bold text into your style sheet you generate HTML like this..
<tr>
<td id="1">
<a name="1" />1</td>
<td> John Doe </td>
<td>1990</td>
<td> JavaScript </td>
<td> 10.99 </td>
</tr>
You can then use books.xml#1 and so on to jump to the right section of the table.
Justin Henley
Hi,
I tried out the files in different locations and they display fine.
Placing #12 at the end of the url doesn't work, but its confusing and not clear what adding #12 does.
Is it an XPointer to item with ID12 or is it to move to an anchor in the rendered HTML named 12.
If its an XPointer then the question is does IE6 support XPointers. I don't think it does but I've been wrong before. I'd check that.
If its an HTML anchor then it won't work because you haven't defined any named anchors in the rendered HTML. Also does a named anchor still work for xml translated to html.
More questions than answers sorry.