Re: xPath and default namespaces.
Hi Dwight, > Is it legal XHTML to give an alias to the XHTML name space ? XHTML is an attempt to marry HTML and XML so that *both* HTML applications *and* XML applications can use it. Using a prefix for the XHTML within a document is perfectly fine as far as an XML application is concerned, but it's not acceptable by HTML applications. But that's by-the-by because David C. was talking about adding a prefixed namespace declaration *within the stylesheet*, not within the XHTML document. Obviously, HTML applications are never going to look at an XSLT stylesheet, so you're not constrained by what they can or can't read. In the stylesheet, you have to associate a prefix with the namespaces of any nodes that you want to select or match (unless they're all in the null namespace). Importantly, this doesn't have to be the same as the prefix that you use in the document you're processing. So you can have your XHTML document use the default namespace (have no prefix) while using 'xhtml' as the prefix in your stylesheet. The XSLT processor uses the *namespace URI* that's associated with each of them, rather than the prefix, to do the matching. So in the stylesheet, you can do things like: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:template match="xhtml:html"> <xsl:apply-templates select="xhtml:body" /> </xsl:template> <xsl:template match="xhtml:body"> ... </xsl:template> </xsl:stylesheet> Not interpreting XPaths using the default namespace is something that can be very useful, but it's recognised as being confusing. From the XSLT 2.0 Requirements, it seems that in XSLT 2.0 there will be a flag or something that you can set that tells the processor to use the default namespace for unprefixed names in XPaths. > I don't include the XHTML DTD because the parser doesn't seem to > like it. Which parser are you talking about? How does it object? An XML parser should be able to use the XHTML DTD to validate your XHTML page, and I think that an HTML application should just ignore it. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format