all your elements in the XML are in the default namespace, so their complete name consists of the namespace-uri and the elment's name. If you want to match such an element, you must declare the namespace in the XSL. There is only one problem with default namespace: You can not simply declare it in the XSL, the matching won't work. You *must* bind it to a prefix. So changing your stylesheet to the following should solve your problem:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="html:link[@rel='stylesheet']"/>
</xsl:stylesheet>
Regards,
Joerg
Anna Afonchenko wrote:
Hi all.
This is not really a Cocoon problem, but maybe you can help me with this.
I have the following XHTML page:
<!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">
<head>
<title>Page</title>
<link href="pics/main_ns.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>Some content</p>
</body>
</html>
and I want to parse it and take out the link to external stylesheet.
So I wrote the following xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="link[@rel='stylesheet']">
</xsl:template>
</xsl:stylesheet>
Here is my pipeline:
<map:match pattern="parseXhtml">
<map:generate src="test.html"/>
<map:transform src="disableCSS.xsl"/>
<map:serialize type="xml"/>
</map:match>
This stylesheet should output the original page without link tag that links to external stylesheet.
The problem is, it doesn't match, e.g. the output is exactly the original input with the link tag left.
If I take out the xhtml declaration from the input file, e.g. delete the doctype declaration and xmlns attribute from the html tag, everything works fine.
Is there any prorblem in Cocoon/xsl while matching files with xhtml declaration?
Can somebody explain this to me.
Sorry if this is a bit unrelated and thanks very much for help.
Anna
--------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>