• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Simple XML/XSL Does not Work??

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Hey, I have made a very simple xml page and an xsl page. I have come to the conclusion,that the xsl page is not getting the values from the xml page. I am listing the codes below. Please see what is it that I am missing? I am using win2000 along with IE 5.0 version.
================================================================
THE XML FILE mca.xml
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="mca.xsl"?>
<mca>
<course_info title="Starter Kit for MCA Students" course_name="Masters in Computer Application">
<course_mode>Integrated Mode</course_mode>
<course_duration>January, 2001</course_duration>
</course_info>
<address>
<department_name>School Of Computer and Information Sciences</department_name>
<university_name>Indira Gandhi National Open University</university_name>
<street>Maidan Garhi</street>
<city>New Delhi</city>
<pincode>110068</pincode>
</address>
</mca>
===============================================================
THE XSL FILE mca.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<title>
<xsl:for-each select="course_info">
<xsl:value-of select="@title"/>
</xsl:for-each>
A Student's Guide
</title>
</head>
<body>
<h1>Does this print
<xsl:for-each select="course_info">
<xsl:value-of select="@course_name"/>
</xsl:for-each>
</h1>
And what about this
</body>
</html>
</xsl:template>
</xsl:stylesheet>
============================================================
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tualha,
There was some error on your XSL code...i have modified the XSL a little bit. Here is the code:
-----------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<xsl:for-each select="mca/course_info">
<head>
<title>
<xsl:value-of select="./@title"/>
<!--A Student's Guide -->
</title>
</head>
<body>
<h1><!--Does this print-->
<xsl:value-of select="./@course_name"/>
</h1>
<!--And what about this-->
</body>
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------------------------------
I didn't know how you wanted the output, so i removed the errors the way i thought the output should be...
I hope this helps..
Shantanu
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!