Forum Moderators: open
My xml file is : CompanyA.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="order.xsl"?>
<order>
<salesperson>John Doe</salesperson>
<item>Production-Class Widget</item>
<quantity>16</quantity>
<date>
<month>1</month>
<day>13</day>
<year>2000</year>
</date>
<customer>Sally Finkelstein</customer>
</order>
My order.xsl file which is used by the above xml file is :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<order>
<date>
<xsl:value-of select="/order/date/year"/>/<xsl:value-of
select="/order/date/month"/>/<xsl:value-of select="/order/date/day"/>
</date>
</order>
</xsl:template>
</xsl:stylesheet>
My output file when i open CompanyA.xml in IE6 is :
2000/1/13
Actually my output should have been:
<order>
<date>2000/1/13 </date>
</order>
The output should have been displayed with the order and the date tags as per the order.xsl
file.But the tags alone are not displayed.
Please help with this problem.
Thanks in advance.
IE hates switching between HTML and XML modes. If the output was not XML to begin with, and you are hitting F5/Refresh, then IE will try to read this as HTML. So your tags aren't rendered.
Also, since your output doesn't identify this as an XML document, IE is probably going to try and read it as HTML. You will need the <?xml version="1.0"?> tag on the first line at a minimum.
I would recommend manually creating a test file with the desired output to see how it works in IE. Once you get that so it displays correctly, then go back to work on the XSL file so that it returns the same format as your test file.
Also, since you are building tags, I would recommend using the <xsl:element> and <xsl:attribute> tags in your XSL file. Something like this:
<xsl:element name="order">
<xsl:element name="date">
<xsl:value-of select="/order/date/year"/>/<xsl:value-of select="/order/date/month"/>/<xsl:value-of select="/order/date/day"/>
</xsl:element>
</xsl:element>
thanks for the reply.I created a test file as per u'r advice and checked ,and the output diaplys the tags in the test file.
also as u said, i changed my order.xsl file to contain the element tags like
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="order">
<xsl:element name="date">
<xsl:value-of select="/order/date/year"/>/<xsl:value-of
select="/order/date/month"/>/<xsl:value-of select="/order/date/day"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
but still i get the output as
2000/1/13
instead of
<order>
<date>2000/1/13</date>
</order>
Any Suggestions?
Once again thanks for u'r reply
also as u said, i changed my order.xsl file to contain the element tags like ...
And again, once an instance of IE reads a URL as HTML, there is no talking sense to it. It won't attempt to parse the URL as XML no matter how many times you refresh it. You need to close the browser window and then open a new one (by clicking the icon, NOT by using File/New/Window)