Thank you very much Joerg, this worked!!!
But now I have a more complex pattern, and it doesn't work again.
I want to have a match that will say this:
for each node, that has a child div node with class name test, copy to the
output only the content of the div.
So, for
<p>
    <div class="test">
        <b>Text inside div</b>
   </div>
</p>

the output should be
<b>Text inside div</b>

This is the template that I wrote:
<xsl:template
match="html:node()[child::node()[name()='div'][@class='test']]">
   <xsl:apply-templates select="descendant::html:div/html:node()"/>
 </xsl:template>

This works (without html: namespace) if the input doesn't have xhtml doctype
and xmlns.
But when I put those, the output is not affected, i.e. the nodeset above is
printed out as is.
What am I doing wrong with namespaces this time?

Thank you very very much for help.
Anna.


----- Original Message -----
From: "Joerg Heinicke" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 16, 2003 7:18 PM
Subject: Re: Problem with xsl parsing xhtml


Hello Anna,

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]>


---------------------------------------------------------------------
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]>

Reply via email to