You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Messing, Elad" <el...@eml-d.villa-bosch.de> on 2005/04/12 12:36:59 UTC
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">
<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">
<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
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