|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: header/footer: How to to separate html-tag in to differe
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








