cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conal Tuohy" <>
Subject RE: JXTemplate, Xpath and Namespace
Date Wed, 13 Apr 2005 03:20:25 GMT
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!


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 [] 
	Sent: Tuesday, 12 April 2005 10:37 p.m.
	Subject: JXTemplate, Xpath and Namespace

	Hello all 
	        I have a newbie question related to Xpath expression and
	        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"
<> "> 
	<html xmlns:bla="http://bla"
	                <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"
<> ">
	<html xmlns:bla="http://bla"
	                <meta http-equiv="Content-Style-Type"

	        As you see, the default namespace <>  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 ? 


	Elad Messing 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message