Subject: [xsl] built in templates question From: Brian Hickey <brian_hickey1@xxxxxxxxx> Date: Fri, 16 Aug 2002 03:54:28 -0700 (PDT) |
Hello all I have a problem trying to overwrite the built-in templates. I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="applyXSL.xsl"?> <manifest> <heading1>Module Geology</heading1> <heading2> Course Information <sub resource="Geo101_readings.doc">Reading List</sub> <sub resource="Geo101_syllabus2.doc">Syllabus</sub> <sub resource="Geo101_schedule.doc">Schedule</sub> </heading2> <heading2 resource="geology_101.htm">"Geology 101"</heading2> <heading3 resource="minerals.htm"> "Minerals" <sub resource="elements.htm">"Class I"</sub> <sub resource="sulfides.htm">"Class II"</sub> <sub resource="halides.htm">"Class III"</sub> <sub resource="oxides.htm">"Class IV"</sub> <sub resource="carbonates.htm">"Class V"</sub> <sub resource="sulfates.htm">"Class VI"</sub> <sub resource="phosphates.htm">"Class VII"</sub> <sub resource="silicates.htm">"Class VIII"</sub> <sub resource="organic.htm">"Class IX"</sub> </heading3> <heading3 resource="rocks.htm"> "Rocks" <sub resource="igneous.htm">"Igneous"</sub> <sub resource="sedimentary.htm">"Sedimentary Rocks"</sub> <sub resource="metamorphic.htm">"Metamorphic"</sub> </heading3> <heading2> Rocks <sub resource="Rock_intro.doc">Rock Introduction</sub> <sub resource="Rock_lecture.doc">Rock Lecture 1</sub> <sub resource="Rock_lecture.ppt">Rock Lecture 2</sub> </heading2> <heading2> Minerals <sub resource="Mineral_intro.doc">Minerals Introduction</sub> <sub resource="Mineral_lecture.doc">Mineral Lecture 1</sub> <sub resource="Mineral_lecture.ppt">Mineral Lecture 2</sub> </heading2> </manifest> I have applied the following XSLT: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="manifest"> <xsl:apply-templates/> </xsl:template> <xsl:template match="heading1"> <h3><xsl:value-of select="."/></h3> <!-- <xsl:apply-templates select="heading2"/>--> </xsl:template> <xsl:template match="heading2"> <xsl:choose> <xsl:when test = "@resource"> <a href="{@resource}"> <xsl:value-of select="."/> </a> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/><br/> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select="heading3"/> <xsl:apply-templates select="sub"/> </xsl:template> <xsl:template match="heading3"> <xsl:choose> <xsl:when test = "@resource"> <a href="{@resource}"> <xsl:value-of select="."/> </a> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/><br/> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select="heading4"/> <xsl:apply-templates select="sub"/> </xsl:template> <xsl:template match="heading4"> <xsl:value-of select="."/> <xsl:apply-templates select="sub"/> </xsl:template> <xsl:template match="sub"> <ul><li><a href="{@resource}"> <xsl:attribute name="target">blank</xsl:attribute> <xsl:attribute name="style">text-decoration:none</xsl:attribute> <font size="2.3" color="#228800"> <xsl:value-of select="."/></font> </a></li></ul> </xsl:template> </xsl:stylesheet> And here is the output I am getting: Module Geology Course Information Reading List Syllabus Schedule - Reading List - Syllabus - Schedule "Geology 101" "Minerals" "Class I" "Class II" "Class III" "Class IV" "Class V" "Class VI" "Class VII" "Class VIII" "Class IX" - "Class I" - "Class II" - "Class III" - "Class IV" - "Class V" - "Class VI" - "Class VII" - "Class VIII" - "Class IX" "Rocks" "Igneous" "Sedimentary Rocks" "Metamorphic" - "Igneous" - "Sedimentary Rocks" - "Metamorphic" Rocks Rock Introduction Rock Lecture 1 Rock Lecture 2 - Rock Introduction - Rock Lecture 1 - Rock Lecture 2 Minerals Minerals Introduction Mineral Lecture 1 Mineral Lecture 2 - Minerals Introduction - Mineral Lecture 1 - Mineral Lecture 2 I would appreciate if someone could tell me how I can prevent the data from the sub-elements being output when I don't need it. Also, I would like to be able to present the output in the form of a navigation menu where the sub elements could be contained in a folder, which would open when clicked on, which I assume would involve using javascript. I haven't used js before so any advice on how I should approach this would also be appreciated. Brian __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:if prob with attribut, Vasu Chakkera | Thread | Re: [xsl] built in templates questi, Jeni Tennison |
Re: [xsl] Re: xsl/xslt coding stand, Jeni Tennison | Date | [xsl] does an element have a unique, Thomas Sandor |
Month |