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.
Can some one please tell me what could be the problem?
Thanks,
Neelima
-
-
your link to the xsl file is looking for styles.xsl in the same folder as the xml file
<?xml
tylesheet href="styles.xsl" type="text/xsl" ?>
therefore you need to copy the styles.xsl file to every folder with an xml file in, or change the href attribute to a generic path that every xml file will look at. -
Yes, both the xml and xsl files are in the same folder.
-
I do not seem to have this issue with the same xml posted, I created two files and the xsl file and put them in a sub folder and it works fine. do you get any errors when you put them in the sub folder or does the xml just show up ?
-
ok heres the scenario....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.
-
I have been able to repro your problem. Now the question is, what might be causing it and how to fix it. So I did a little experiment and created a sub directory off my c drive I called it test and then try it from there. Ok no problem, maybe there is something with the sub directory so I created a sub directory of test called test. Again no problem. so there is someting unusuall about the destop. Well for one thing it is a subdirectory of "Documents and Settings" which has spaces in the directory name. So that might have something to do with it.
Also there might be a problem with your html that you are generating with the xslt. I thought you need to use the "a name=" tag to create a tag on the page to use the # in the address bar.
Looking at those two things see if you can figure out what the problem is. -
jvervoorn wrote:I thought you need to use the "a name=" tag to create a tag on the page to use the # in the address bar.
No. For one thing, the name attribute is deprecated in XHTML 1.0 and gone in XHTML 1.1, and furthermore every element with an id attribute can be the target of a fragment specifier (#). -
Just for the heck of it, I tried opening the file in firefox and the table didn't show up, just the raw text. So I looked up the syntax for embeding xsl in a xml file and you seem to be using the wrong syntax?
It should be:
<?xml-stylesheet
instead of
<?xml:stylesheet
Changeing that got it to work in firefox but opera still apears as raw text. -
jvervoorn
I think <?xml-stylesheet> or <?xml:stylesheet> makes the difference only in Firefox...But I am talking about making it work in IE6.
And definitely it is not the issue of spaces in the folder name because I tried creating it in c:\program files and it worked fine for me.
Can somebody really help me with this....
-
pls help...its kinda urgent...
-
Neelima wrote:ok heres the scenario....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.
Maybe I'm not getting the point...
But you DO realize that according to your post you are changing the extention of the file to be xml#12 instead of regular .xml right?
Would the problem be solved simply by adding 12 to the end of the file name? Example: books12.xml
I dunno if # is a valid file name character AND I dunno if it is some type of path terminator...even if it wasn't your computer is going to look for a way to open that and since no file association occurs natively with .xml#12...you're kinda causing more problems then the
"Please hurry it's important" anyways... -
Cybermagellan wrote:Maybe I'm not getting the point...
You're not getting the point.
His xml file is named books.xml. Putting #12 at the end of a URL means it's a fragment identifier, it causes IE to scroll to the element with that ID. It's that bit which doesn't work, it has nothing to do with the file name. -
Sven Groot is right.
The #12 does not cater to the file name but a fragment identifier.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.