Re: Another DOM and XSL incompatibility?

Subject: Re: Another DOM and XSL incompatibility?
From: James Clark <jjc@xxxxxxxxxx>
Date: Tue, 29 Dec 1998 11:01:26 +0700
Tyler Baker wrote:
 
> In the DOM Attributes are not considered children of elements, yet in
> XSL it seems that through the pattern matching capabilities the
> Attribute nodes are considered to be SubNodes which I interpret as
> "children" of element nodes.

The spec needs a term to mean child node or attribute node.  It uses
"subnode" for this; a subtree rooted at some element includes both the
children and the attributes.  This doesn't mean that attributes are
children.

>  There is an easy workaround to make the
> change (simply delegate recursive processing from the element node's
> children to the attribute nodes children as if the attribute node was
> not even there) but I am not so sure from reading the spec if this is
> the intended behavior.
> 
> In other old spec, you had attribute patterns which could only be the
> last component pattern in an ancestry pattern.  That was the rule.
> 
> Now you could have something like:
> 
> foo/@bar/baz
> 
> in a select pattern without this being a formal error.  I suppose all
> the XSL Processor would do here is always ignore "baz" since you will
> never have an element node as a child of an attribute node.

Right.

>  One thing I
> have not found in the spec is whether this should be regarded as an
> error

The spec doesn't say it's an error, so it's not an error, though it
would be reasonable to give a warning.

Detecting all unmatchable patterns would be tricky.  Consider something
like:

foo[bar and not(bar)]


> or just something that should be ignored as only a fool would try
> and add elements to attributes as children.

If you put an element inside an xsl:attribute, it's an error.  In an XML
tree you can't an attribute can't have an element child, and XSL only
operates on XML trees, so the situation doesn't arise in XSL.

>  I am a little confused as
> to whether you should select the element which has a "bar" attribute or
> whether to select the "bar" attribute itself.

The latter.

>  Furthermore, if you do
> indeed select the attribute (this is what my interpretation of the draft
> says) then what if someone does something like:
> 
> foo/@bar/@baz
> 
> Should this be legal to or else just ignored...

There's nothing in the spec that makes it illegal, so it's legal. There
will never be any nodes that are selected by the pattern since attribute
nodes can't have attributes.

James



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread