This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Newbie question--applying templates, selecting paragraphs


Hi all,

I have an xHTML file to which I need to apply a style sheet in order to copy
CERTAIN paragraphs to a new HTML file.  Now of course, as a newbie, I didn't
know how to do this.  After searching the archives, I found code that copies
ALL paragraphs to the new file.  So this is what I have so far:

----------------------xHTML file--------------------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">

<head>
<title>Testing Title</title>
</head>
<body>
	<div class="mgronly">
		<p>The first paragraph applies only to managers.</p>
	</div>
	<div class="both">
		<p>Paragraph 2 applies to both investigators and
managers.</p>
		<p>The third paragraph to both.</p>
	</div>
	<div class="mgronly">
	<p>The last paragraph applies only to managers.</p>
	</div>
</body>

</html>
--------------------end xHTML file--------------------------------

---------------------- XSL file-----------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

	<xsl:output method="xml" encoding="UTF-8"/>

	<!-- Match the root node -->
	<xsl:template match="*">
		<xsl:apply-templates select="*"/>
	</xsl:template>

	<!-- Handle any node not yet matched -->
	<xsl:template match="*|@*|text()|comment()">
		<xsl:copy>
			<xsl:apply-templates
select="*|@*|text()|comment()"/>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>
---------------------- XSL file-----------------------------------

----------------------- Result -----------------------------------
The first paragraph applies only to managers.

Paragraph 2 applies to both investigators and managers.

The third paragraph to both.

The last paragraph applies only to managers.
----------------------- Result -----------------------------------

So far so good.  But now, when I try to modify the XSL file so only <div>'s
with a certain class are copied out, nothing works.  I either get a blank
screen or I get the title text and all the paragraphs strung together with
no breaks between them.  I could tell you everything I've tried, but it
would probably be faster if someone could just explain how to modify the xsl
file so it copies out only <div>'s of a certain class.

Just when I think I've understood something in XSL, I try code that seems
like it should work and it doesn't.  Very confusing.  So I really appreciate
the help.

Kathryn

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]