Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 16th, 2007, 08:22 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl:template problem

Hi, I am have problems styling by XML document. There seems to be a problem applying my templates. Can you help? I have attached XML and XSLT. This is really bugging me.

XML
----
<courses>
  <course>
     <id>1</id>
     <course_title>Italian (TSM)</course_title>
     <course_letters>Bachelor in Arts (Moderatorship (B.A. with honors))</course_letters>
     <cao_code>TR001</cao_code>
     <subject_area>Italian</subject_area>
     <min_entry_points>300</min_entry_points>
     <min_entry_points_url>http://www.gcd.ie/Admisions</min_entry_points_url>
     <course_faculty>ARTS</course_faculty>
     <course_qual> Joint Honor Degree</course_qual>
     <course_duration>4</course_duration>
     <academic_year>2008</academic_year>
     <fulltime>1</fulltime>
     <mature_apply_to>CAO + Admissions Office, </mature_apply_to>
     <non_eu_apply_to>Office for International Student Affairs, Trinity College</non_eu_apply_to>
     <course_deadline>0000-00-00</course_deadline>
     <available_places>23</available_places>
     <course_url>www.gcd.ie/Classics/</course_url>
     <admission_requirements>
      <p1>Italian cannot be studied as a single honor course. It must either be combined with one other subject within the two-subject moderatorship (TSM) programme or be selected as one of the two languages studied in the European studies programme.</p1>
      <p1>TSM is a joint honors programme. Both subjects are studied for three years and one subject only is studied in the fourth year. An honors degree is awarded in both subjects.
         Italian can be studied ab initio (from beginner level) within both TSM and European studies.
         See also: <links><link name="TR024: European studies Italian with French/German/Polish/Russian or Spanish" url="http://www.gcd.ie/Admissions"/></links>.</p1>
     </admission_requirements>
     <course_content>
        <h5>Overview</h5>
        <p>Italy has played a leading role in European civilisation, and today is one of the major economies of the world, famous for its style, design and innovation in many fields. There is widespread interest in Italy, its people and culture and the courses at Trinity offer an opportunity to develop this interest in a systematic way. They are also designed to help you meet the challenge of becoming proficient in a new language, as you can study Italian here as a complete beginner. There is close contact between students of Italian and staff; you will receive individual attention and will be encouraged to discuss your progress at all times.</p>
        <h5>Is this the right course for you?</h5>
        <p>Italian is an excellent subject choice if you have a natural flair for languages, if you enjoy travelling to foreign countries and exploring their cultures, or if you want to follow a career in the multilingual Europe of today. </p>
        <h5>The Freshman years</h5>
        <p>In the Junior Freshman (first) year you will follow an intensive beginners course in grammar, translation, conversation, and video work. </p>
        <p>There are about eight classroom hours per week, most of the time being devoted to language learning in your first year. Each week includes grammar, conversation class and other activities, and assignments to be done independently. You will be introduced to modern Italian poetry, drama and fiction in your second and third terms through weekly lectures. </p>
        <p>In the Senior Freshman (second) year you continue with language courses and the study of core literary texts. In addition you will follow two optional subjects in areas of particular interest, which may include Italian history and society, avant garde writers in the 0th century and the works on fascism by Carlo Levi and Ignazio Silone. </p>
        <h5>The Sophister years</h5>
        <p>The Junior and Senior Sophister (third and fourth) years focus on major authors of the medieval, Renaissance and later centuries. Optional courses are available in modern Italian literature, history and society, and in linguistic topics such as the theory and practice of translation. There is a continuing emphasis on strengthening your language proficiency and developing higher-level skills in translation, text editing and writing. </p>
        <p>In your final year the programme includes courses on Italian language varieties, the works of Dante, the history of language and a wide selection of optional topics for study in depth. You will also be required to research and write a dissertation. </p>
        <h5>Assessment structure</h5>
        <p>Written, oral and aural examinations, in addition to essays and continuous assessment of your coursework are all used within the Italian department. Senior Sophisters will, in addition, need to complete a final year dissertation. </p>
        <h5>Study abroad</h5>
        <p>A minimum two-month stay in Italy will be required of you at some time over the duration of your course. You may apply to spend the second year at a European university through the SOCRATES programme. There are links with the University of Bologna, the University of Trieste and the University of Pavia. Students who do not opt to participate in an exchange programme may substitute one subject in Italian with a course offered through the Broad Curriculum initiative in either the second or third year (see <links><link name="www.tcd.ie/Broad_Curriculum" url="http://www.tcd.ie/Broad_Curriculum"/></links>). </p>
        <h5>Career opportunities</h5>
        <p><image><img src="http://www.tcd.ie/images/camp1.jpg" alt="camp" /></image> Recent graduates who have progressed directly to employment have chosen careers ranging from PR and translation through teaching to internships with Irish companies in Italy, working with both governmental and commercial organisations. Of the graduates who opted for further study, some selected related courses in arts, social sciences, and European studies while others have selected law, marketing, journalism or teacher training. </p>
        <h5>Special Entry Requirements</h5>

        [list]
        <li>Introductory module</li>
        <li>Microbiology and Cross infection control</li>
        <li>Dental and Oral Pathology</li>
        <li>Physiology and medical emergencies</li>
        <li>Clinical Dentistry I</li>
        <li>Computer course(ECDL)</li>
        <li>Masticatory System</li>
        <li>Oral Health and the Community</li>
        <li>Psychology and Social Concepts in patient care</li>
        <li>Clinical Dentistry II</li>
        </ul>
     </course_content>
  </course>
</courses>

Here is my XSLT
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!--
  <xsl:template match="course">
      <h5><xsl:apply-templates select="course_title"/></h5>
      <h5><xsl:apply-templates select="course_letters"/></h5>
      <p><xsl:apply-templates select="admission_requirements"/></p>
   </xsl:template> -->

  <xsl:template match="h5">
      <h5><xsl:apply-templates /></h5>
  </xsl:template>

  <xsl:template match="p">
    <p><xsl:apply-templates /></p>
  </xsl:template>

  <xsl:template match="link">
     <a href="{@url}"><xsl:value-of select="@name" /></a>
  </xsl:template>

  <xsl:template match="img">
     <img src="{@src}" alt="{@alt}" align="left" width="100" height="150" hspace="5"/>
  </xsl:template>

  <xsl:template match="ul">
     [list]
     <xsl:for-each select="li">
      <li><xsl:value-of select="text()"/></li>
     </xsl:for-each>
    </ul>
  </xsl:template>

    <xsl:template match="ol">
     <ol>
     <xsl:for-each select="li">
      <li><xsl:value-of select="text()"/></li>
     </xsl:for-each>
    </ol>
    </xsl:template>
</xsl:stylesheet>
Reply With Quote
  #2 (permalink)  
Old August 16th, 2007, 08:40 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

There are many elements in your source for which there is no matching template rule in your XSLT. The default template rule outputs the text content of the element, with no markup.

If you want different behaviour, write a fallback template rule, for example

<xsl:template match="*"/>

which deletes all such elements, or

<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

which copies them.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: template reuse ramesh.kumarm XSLT 16 December 1st, 2006 06:27 AM
xsl:call-template name="$variable" problem chemi XSLT 1 October 6th, 2005 07:28 AM
xsl:template match 'overlapping' ? Kabe XSLT 1 February 25th, 2005 06:03 AM
xsl template concat problem nambati XSLT 5 January 31st, 2005 03:43 PM
help with xsl template match enT XSLT 9 September 24th, 2003 06:21 AM



All times are GMT -4. The time now is 03:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.