Subject: Re: [xsl] Complete newbie stupid question From: Mike Brown <mike@xxxxxxxx> Date: Thu, 1 Aug 2002 12:22:48 -0600 (MDT) |
Sandra Mcdonnell wrote: > Hi, I'm new to the list, to XML, to XSL, XSLT and pretty much everything > related. > > I am trying to do what seems like a simple operation. I just want a > stylesheet that calls a template in which nested templates specify > formatting for specific nodes. You don't nest templates, except when you're using xsl:for-each. The match attribute on xsl:template does not mean "go find and process nodes that match this pattern". It means "I declare that this template is good for processing a node that matches this pattern". It is the xsl:apply-templates instruction that selects nodes for processing. Processing begins at the root node, so the template that matches the root node needs to have an xsl:apply-templates in it to select other nodes for processing. The best matching templates for those nodes are then instantiated in a certain order, depending on how the selection was made. There are built-in templates for each type of node, so you will always have a match, and a default behavior of traversing through most of the source tree if you don't override any of them. I have no idea what kind of HTML you were trying to produce; this business you had in your example is just wrong in so many ways... <html> <font face="Arial" color="black" size="24" style="bold"/> <br/> </html> I don't know what your XML looks like, either, but this should give you the general idea. Adjust the path/to/Head1 as necessary to match your source tree. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="iso-8859-1"/> <xsl:template match="/"> <html> <head> <title>foo</title> </head> <body> <xsl:apply-templates select="/path/to/Head1"/> </body> </html> </xsl:template> <xsl:template match="Head1"> <h1> <xsl:value-of select="."/> </h1> </xsl:template> </xsl:stylesheet> - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Complete newbie stupid qu, Jeni Tennison | Thread | RE: [xsl] Complete newbie stupid qu, Jeff Beadle |
Re: [xsl] Complete newbie stupid qu, Jeni Tennison | Date | RE: [xsl] Complete newbie stupid qu, Jeff Beadle |
Month |