Arbitrator
01-07-2007, 12:20 AM
Basically, I want to pull the (XHTML) content of the content element and output it directly (as XHTML) in the <xht:div id="content"> element via the XSLT template. Unfortunately, I don’t know how to import the content of the content element in such a way. Would appreciate some help with this.
Below are the template and document, with some color‐coded code and comments to indicate the relevant areas.
Here’s the XSLT template:
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xht="http://www.w3.org/1999/xhtml">
<output method="html" media-type="application/xhtml+xml" omit-xml-declaration="no" version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
<template match="document">
<xht:html xml:lang="en-US">
<xht:head>
<xht:title>Just Some Guy’s Place: <value-of select="headers/title"/></xht:title>
<xht:meta name="Author" content="{headers/author}"/>
<xht:style type="text/css">
@import url("master.css") screen;
</xht:style>
</xht:head>
<xht:body>
<xht:div id="header">
<xht:h1>Just Some Guy’s Place</xht:h1>
</xht:div>
<xht:div id="navigation">
<xht:ul>
<xht:li>one</xht:li>
<xht:li>two</xht:li>
<xht:li>three</xht:li>
<xht:li>four</xht:li>
<xht:li>five</xht:li>
<xht:li>six</xht:li>
<xht:li>seven</xht:li>
<xht:li>eight</xht:li>
<xht:li>nine</xht:li>
<xht:li>ten</xht:li>
</xht:ul>
</xht:div>
<xht:div id="content">
<!-- Import raw XHTML from "content" element to here. -->
<!-- The raw XHTML should be output as identical XHTML. -->
</xht:div>
<xht:div id="footer">
And they lived happily ever after.
</xht:div>
</xht:body>
</xht:html>
</template>
</stylesheet>
Here’s the XML document:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="master.xsl"?>
<document xmlns:xht="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<headers>
<title>Rōmaji, Hiragana, and Katakana Table</title>
<author>Patrick Garies</author>
<created>2007 January 6</created>
<updated>2007 January 6</updated>
<presentation type="text/css">
…
</presentation>
</headers>
<content>
<!-- I want to pull the XHTML content of this element. -->
<xht:table>
<xht:caption>
<xht:span>
<xht:span class="pre">
<xht:span xml:lang="ja">Rōmaji</xht:span> (<xht:span xml:lang="ja">ローマ字</xht:span>),
</xht:span>
<xht:span class="pre">
<xht:span xml:lang="ja">Hiragana</xht:span> (<xht:span xml:lang="ja">平仮名</xht:span>),
</xht:span> and
<xht:span class="pre">
<xht:span xml:lang="ja">Katakana</xht:span> (<xht:span xml:lang="ja">片仮名</xht:span>)
</xht:span> Table
</xht:span>
</xht:caption>
<xht:thead xml:lang="ja">
<xht:tr>
<xht:th id="rōmaji"><xht:abbr title="Rōmaji">R</xht:abbr></xht:th>
…
<!-- The remainder of the table is truncated here. -->
</content>
</document>
Below are the template and document, with some color‐coded code and comments to indicate the relevant areas.
Here’s the XSLT template:
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xht="http://www.w3.org/1999/xhtml">
<output method="html" media-type="application/xhtml+xml" omit-xml-declaration="no" version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
<template match="document">
<xht:html xml:lang="en-US">
<xht:head>
<xht:title>Just Some Guy’s Place: <value-of select="headers/title"/></xht:title>
<xht:meta name="Author" content="{headers/author}"/>
<xht:style type="text/css">
@import url("master.css") screen;
</xht:style>
</xht:head>
<xht:body>
<xht:div id="header">
<xht:h1>Just Some Guy’s Place</xht:h1>
</xht:div>
<xht:div id="navigation">
<xht:ul>
<xht:li>one</xht:li>
<xht:li>two</xht:li>
<xht:li>three</xht:li>
<xht:li>four</xht:li>
<xht:li>five</xht:li>
<xht:li>six</xht:li>
<xht:li>seven</xht:li>
<xht:li>eight</xht:li>
<xht:li>nine</xht:li>
<xht:li>ten</xht:li>
</xht:ul>
</xht:div>
<xht:div id="content">
<!-- Import raw XHTML from "content" element to here. -->
<!-- The raw XHTML should be output as identical XHTML. -->
</xht:div>
<xht:div id="footer">
And they lived happily ever after.
</xht:div>
</xht:body>
</xht:html>
</template>
</stylesheet>
Here’s the XML document:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="master.xsl"?>
<document xmlns:xht="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<headers>
<title>Rōmaji, Hiragana, and Katakana Table</title>
<author>Patrick Garies</author>
<created>2007 January 6</created>
<updated>2007 January 6</updated>
<presentation type="text/css">
…
</presentation>
</headers>
<content>
<!-- I want to pull the XHTML content of this element. -->
<xht:table>
<xht:caption>
<xht:span>
<xht:span class="pre">
<xht:span xml:lang="ja">Rōmaji</xht:span> (<xht:span xml:lang="ja">ローマ字</xht:span>),
</xht:span>
<xht:span class="pre">
<xht:span xml:lang="ja">Hiragana</xht:span> (<xht:span xml:lang="ja">平仮名</xht:span>),
</xht:span> and
<xht:span class="pre">
<xht:span xml:lang="ja">Katakana</xht:span> (<xht:span xml:lang="ja">片仮名</xht:span>)
</xht:span> Table
</xht:span>
</xht:caption>
<xht:thead xml:lang="ja">
<xht:tr>
<xht:th id="rōmaji"><xht:abbr title="Rōmaji">R</xht:abbr></xht:th>
…
<!-- The remainder of the table is truncated here. -->
</content>
</document>