Click to See Complete Forum and Search --> : Page not displaying


florida
03-29-2005, 10:55 AM
I am new to XML and trying to get an xml page to show up.
Please advise what exactly I need to do to get this to work??

Here is the xml page called two.xml:

<?xml version="1.0"?>
<xsl-stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="talltales/tt">
<div style="width:750px; padding:10px; margin-bottom: 10px; border: 4px double black; background-color:silver">
<xsl:apply-templates select="question"/>
<xsl:apply-templates select="a"/>
<xsl:apply-templates select="b"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>

<xsl:template match="question">
<div style="color:black; font-family: Times; font-size:16pt">
<xsl:value-of/>
</div>
</xsl:template>

<xsl:template match="a|b">
<div style="color:black; font-family: Times; font-size:12pt; text-indent:20px">
<xsl:value-of/>
</div>
</xsl:template>
</xsl:stylesheet>


Now here is the page called talltales.xml:

<?xml version="1.0" ?>
<talltales>
<tt answer="a">
<question>
This is the first question
</question>
<a>This is the a part</a>
<b>This is the a with b part</b>
</tt>
<tt answer="b">
<question>
This is the second question
</question>
<b>This is the b part</b>
</tt>
</talltales>


When I try and display two.xml it says:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
End tag 'xsl:stylesheet' does not match the start tag 'xsl-stylesheet'. Error processing resource 'http://myserver/two.xml'. Line 30, Position 3
</xsl:stylesheet>
--^



Did I diplay the wrong page or what do I need to do?

Jona
03-29-2005, 11:31 AM
Shouldn't it be two.xsl?

florida
03-29-2005, 12:21 PM
I just tried two.xsl and it gives me same error. Please advise.

Jona
03-29-2005, 12:49 PM
The last line of "two.xsl" should be </xsl-stylesheet> not </xsl:stylesheet>. You should be opening talltales.xml and importing two.xsl from talltales.xml, because the XML file is what holds the data and the XSL stylesheet is what defines the format that the XML file uses.

Jona
03-29-2005, 01:57 PM
Here's a working example of your code. The XML file (talltales.xml) should look like this:


<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="two.xsl"?>
<talltales>
<tt answer="a">
<question>
This is the first question
</question>
<a>This is the a part</a>
<b>This is the a with b part</b>
</tt>

<tt answer="b">
<question>
This is the second question
</question>
<b>This is the b part</b>
</tt>
</talltales>


And the XSL stylesheet (two.xsl) should look like this:


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" omit-xml-declaration="no" />
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="talltales/tt">
<div style="width:750px; padding:10px; margin-bottom: 10px; border: 4px double black; background-color:silver">
<p><xsl:apply-templates select="question" /></p>
<p><xsl:apply-templates select="a" /></p>
<p><xsl:apply-templates select="b" /></p>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

florida
03-29-2005, 01:58 PM
Thanks,

I tried this in the talltales.xml page and it just outputs the xml page with no style output on it. Please advise if there is something else im missing?

<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="two.xsl"?>

<talltales>
<tt answer="a">
<question>
This is the first question
</question>
<a>This is the a part</a>
<b>This is the a with b part</b>
</tt>
<tt answer="b">
<question>
This is the second question
</question>
<b>This is the b part</b>
</tt>
</talltales>


Here is the xsl file (two.xsl):

<?xml version="1.0"?>
<xsl-stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="talltales/tt">
<div style="width:750px; padding:10px; margin-bottom: 10px; border: 4px double black; background-color:silver">
<xsl:apply-templates select="question"/>
<xsl:apply-templates select="a"/>
<xsl:apply-templates select="b"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>

<xsl:template match="question">
<div style="color:black; font-family: Times; font-size:16pt">
<xsl:value-of/>
</div>
</xsl:template>

<xsl:template match="a|b">
<div style="color:black; font-family: Times; font-size:12pt; text-indent:20px">
<xsl:value-of/>
</div>
</xsl:template>
</xsl-stylesheet>

Jona
03-29-2005, 02:02 PM
I think you missed my previous post.

florida
03-29-2005, 02:06 PM
Thanks,

I tried this in the talltales.xml page and it just outputs the xml page with no style output on it. Please advise if there is something else im missing?

<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="two.xsl"?>

<talltales>
<tt answer="a">
<question>
This is the first question
</question>
<a>This is the a part</a>
<b>This is the a with b part</b>
</tt>
<tt answer="b">
<question>
This is the second question
</question>
<b>This is the b part</b>
</tt>
</talltales>


Here is the xsl file (two.xsl):

<?xml version="1.0"?>
<xsl-stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="talltales/tt">
<div style="width:750px; padding:10px; margin-bottom: 10px; border: 4px double black; background-color:silver">
<xsl:apply-templates select="question"/>
<xsl:apply-templates select="a"/>
<xsl:apply-templates select="b"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>

<xsl:template match="question">
<div style="color:black; font-family: Times; font-size:16pt">
<xsl:value-of/>
</div>
</xsl:template>

<xsl:template match="a|b">
<div style="color:black; font-family: Times; font-size:12pt; text-indent:20px">
<xsl:value-of/>
</div>
</xsl:template>
</xsl-stylesheet>

Jona
03-29-2005, 02:12 PM
Why did you reply with the same message twice? Look at the code you're using and compare it to mine.

florida
03-29-2005, 03:18 PM
Thanks Jona for your assistance, patience and getting it to work.

Sorry I replied twice because the page hung up on me on my reply and I hit the submit button twice.

Jona
03-29-2005, 03:28 PM
Not a problem. For a minute there I was sort of confused, though, since you seemed to be ignoring my previous post as if you didn't want to do it the way I proposed. Anyway, glad you got it working.