Subject: Re: [xsl] Find the root element from an attribute node|
From: "Vladimir Nesterovsky" <vladimir@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Jul 2008 18:39:11 +0300
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xpath-default-namespace="http://www.w3.org/1999/xhtml" ...
OK. So none of these work - and why not? Do I really have to assign a namespace? Remember, I'm processing documents from different namespaces so I'd rather not.
Here is an example of the document followed by the xsl that doesn't work.
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="file:/c:/SSPub/15/17/System/xhtml/css/xhtml.css" type="text/css"?> <!DOCTYPE html SYSTEM "file:/c:/SSPub/15/17/System/xhtml/dtd/xhtml1-transitional.dtd"> <html id="a-4238b08e-10f858ce772--2dd4" xmlns="http://www.w3.org/1999/xhtml"> </html>
Xsl: <?xml version='1.0'?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/html"> Boo to a goose </xsl:template> </xsl:stylesheet>
Is there a way to say "any namespace"? Why isn't that the default?
-----Original Message----- From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: 10 July 2008 15:00 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Find the root element from an attribute node
I want to detect whether the ancestor of the particular href is <html> as opposed to <map>, <task>, <concept> or <reference> so that I can treat it differently. How do I do it?
Is never going to work.
Why not? match="html//@href" is more conventional, but your form is just as
good. It assumes, of course, that you somewhere do apply-templates to the
I've read with bewilderment the threads about the xslt spec and that attributes are children of elements but elements are not parents of children...
No you've got that the wrong way around.
The relationship between elements and subelements is called "child" in one direction and "parent" in the other.
The relationship between elements and attributes is called "attribute" in one direction and "parent" in the other.
You can always go up from an attribute using the parent or ancestor axes.
Michael Kay http://www.saxonica.com/