RE: [xsl] xhtml XPath problem

Subject: RE: [xsl] xhtml XPath problem
From: "Dion Houston" <dionh@xxxxxxxxxxxxx>
Date: Thu, 16 May 2002 12:47:57 -0700
Actually the issue is not per se with XHTML.  It's the fact that your
elements are assigned to a namespace.  In XPath, expressions such as
"foo" will only match a foo element if it has a NULL namespace.

Otherwise, assign the namespace to an arbitrary prefix in your XSL and
use that prefix to refer to the element, i.e.

<xsl:stylesheet ... xmlns:x="";>
     <xsl:value-of select="$source/x:html/x:head/x:title" />


-----Original Message-----
From: Doug Chestnut [mailto:dhc4z@xxxxxxxxxxxx] 
Sent: Thursday, May 16, 2002 12:32 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] xhtml XPath problem

I am having trouble with XPath when trying to match elements in an xhtml

document stored in an xsl:variable.  I have no trouble when the xhtml is

missing its DOCTYPE declaration, but can't match elements when the xhtml

is conforming.  I used xalan for this example:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="";  >
<title>test doc</title>
<meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1" />


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   <xsl:variable name="source" select="/" />
   <xsl:template match="/">
     <xsl:value-of select="$source/html/head/title" />


<?xml version="1.0" encoding="UTF-8"?>

I would like to see the title "test doc" there but it is not.  If I 
modify my test.html file it works:


<title>test doc</title>
<meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1" />


<?xml version="1.0" encoding="UTF-8"?>
test doc

Can anyone let me know why this is not working with a valid xhtml 
Thanks in advance for any help,


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread