Francis Hwang
Usenet Archive
- Joined
- Aug 3, 2003
- Messages
- 301
- Reaction score
- 0
Hi,
Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags?
I can imagine that this request might be against the spirit of XML in general, but the reason I'm trying to do this is that I want to use XSLT for simple generation of XHTML. Basically I want the page's contents in external files, then I want to include them into a wrapper of the basics (header info, site navigation, etc.) using XSLT. (Of course you could also just use something else like server-side includes for this but I like the idea of XSLT implicitly forcing well-formedness on the documents it processes.) So I have an XSL file that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0"> <head> <title>My web site</title> </head> <body> <p id="page_head"> <!--- page header graphic ---> </p> <hr /> <div id="page_content"> <xsl:copy-of select="page_content" /> </div> <div id="site_nav"> <!--- site navigation ---> </div> </body> </html>
and I want to be able to process a bunch of different files where I know nothing about them except for that their root element is <page_content>. Could be:
<page_content>nothing much here.</page_content>
or
<page_content>Here's the list of every book I ever read:
<ol>
<li><cite>Ulysses</cite> by James Joyce</li>
<!--- more books --->
</ol>
</page_content>
xsl:value-of strips out any contained tags. xsl:copy-of retains all the contained XML tags, but it also keeps the <page_content> tag, of course, meaning that it shows up in the final XHTML. Is there a way to say "whatever's in this element, include it all in order, but don't actually include 'page_content' at the beginning or the end" ?
Thanks in advance,
Francis
Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags?
I can imagine that this request might be against the spirit of XML in general, but the reason I'm trying to do this is that I want to use XSLT for simple generation of XHTML. Basically I want the page's contents in external files, then I want to include them into a wrapper of the basics (header info, site navigation, etc.) using XSLT. (Of course you could also just use something else like server-side includes for this but I like the idea of XSLT implicitly forcing well-formedness on the documents it processes.) So I have an XSL file that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0"> <head> <title>My web site</title> </head> <body> <p id="page_head"> <!--- page header graphic ---> </p> <hr /> <div id="page_content"> <xsl:copy-of select="page_content" /> </div> <div id="site_nav"> <!--- site navigation ---> </div> </body> </html>
and I want to be able to process a bunch of different files where I know nothing about them except for that their root element is <page_content>. Could be:
<page_content>nothing much here.</page_content>
or
<page_content>Here's the list of every book I ever read:
<ol>
<li><cite>Ulysses</cite> by James Joyce</li>
<!--- more books --->
</ol>
</page_content>
xsl:value-of strips out any contained tags. xsl:copy-of retains all the contained XML tags, but it also keeps the <page_content> tag, of course, meaning that it shows up in the final XHTML. Is there a way to say "whatever's in this element, include it all in order, but don't actually include 'page_content' at the beginning or the end" ?
Thanks in advance,
Francis