Hi Elad

In XSLT 1.0 you cannot match a namespaced element UNLESS you use a
namespace prefix. If the input document uses a default namespace (i.e.
with no prefix), you can still match it, but your template/@match
expressions MUST use a prefix. 

In your XSLT, bind the XHTML namespace to a prefix, and use that prefix
in your match expressions, e.g. "//xhtml:head" instead of "//head". This
will match even if the XHTML namespace in the input document is the
default namespace (i.e. without a prefix). 

Hope that helps!

Con

PS this isn't a Cocoon issue as such - you're usually better off to ask
this type of question on the MulberryTech XSL mail-list.


________________________________

        From: Messing, Elad [mailto:[EMAIL PROTECTED] 
        Sent: Tuesday, 12 April 2005 10:37 p.m.
        To: users@cocoon.apache.org
        Subject: JXTemplate, Xpath and Namespace
        
        

        Hello all 
                I have a newbie question related to Xpath expression and
Namspaces. 
                Here goes : 
                I have an XHTML page. It looks like this : 


        <?xml version="1.0" encoding="ISO-8859-7"?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
<http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> "> 
        <html xmlns:bla="http://bla";
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";> 
                <head> 
                        <title>title</title> 
                        <meta http-equiv="Content-Style-Type"
content="text/css" /> 
        . 
        . 
        . 


                Then I pass it through the JXTemplate generator, which
changes it to the xml that look like this : 

        <?xml version="1.0" encoding="ISO-8859-1"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
<http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> ">
        <html xmlns:bla="http://bla";
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";
xmlns="http://www.w3.org/1999/xhtml";>
                <head>
                        <title>title</title>
                        <meta http-equiv="Content-Style-Type"
content="text/css"/>
        . 
        . 
        . 


                As you see, the default namespace
http://www.w3.org/1999/xhtml <http://www.w3.org/1999/xhtml>  was added
to the html declaration. Now - when I try to match     a template in
this xml document - I.E. " //head " the Xpath doesn't find the node -
because it is actually connected    to the default namespace, and Xpath
will not return the <head> element. I think that for Xpath there is no
such         thing as default namespace.

                I know I can use the Xpath expression with *[1] and etc
to reach the desired node- but this is not very elegant.

                So my question is - What should be done in this case ? 
                Should I have the JXTemplate generator to not add the
defualt namespace ? How ? 
                Or maybe this is not the right direction ? 

                Thanks 


        Elad Messing 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to