Subject: Re: header/footer: How to to separate html-tag in to different xsl-template rules? From: Mike Brown <mike@xxxxxxxx> Date: Fri, 23 Jun 2000 11:55:26 -0600 (MDT) |
> How could I separate headers and footers in my xsl-templates? My problem > is, that I cannot have a tag like "body" in an <xsl:template>, whithout > closing it. > > So how to do: > > <xsl:template match="header"> > <html> > <head> > </head> > <body> > </xsl:template> > > <xsl:template match="footer"> > </body> > </html> > </xsl:template> XSLT does not operate on tags. It operates on a tree of nodes that is implied by the markup. For example, <html> <head>head stuff</head> <body>body stuff</body> </html> has a node tree like root |___element 'html' |___text '\n ' |___element 'head' | |___text 'head stuff' |___text '\n ' |___element 'body' |___text 'body stuff' Furthermore, the markup you are putting in the stylesheet is not a specification for literal output. It is a specification for how the XSLT processor should go about creating another node tree, the 'result tree'. Your HTML output will be *derived* from this result tree after it is created. Not only that, but the XSLT itself is XML, and must be well-formed. So begin thinking in terms of complete elements: <xsl:template match="doc"> <html> <head> <xsl:apply-templates select="doc_head"/> </head> <body> <xsl:apply-templates select="content"/> </body> </html> </xsl:template> ...just as an example. - Mike ____________________________________________________________________ Mike J. Brown, software engineer at My XML/XSL resources: webb.net in Denver, Colorado, USA http://www.skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: header/footer: How to to separa, Warren Hedley | Thread | format the date, SAUREL Eric |
Re: anchors - links on the same *.x, Carlos Araya | Date | Re: anchors - links on the same *.x, Robert Koberg |
Month |