Re: [xsl] Copying a document except specific root attribute

Subject: Re: [xsl] Copying a document except specific root attribute
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Mon, 13 Jun 2005 10:24:57 -0500
> For starters, I use the identity transformation to copy all elements and
> attributes of an XML document. Additionally, I have a rule like:
>
> <xsl:template match="/@myRootAttribute"/>

Of course it's ignoring that attribute.  It can't exist ;).  /
designates document root, the parent of the document element.

See XPATH 1.0: "/ selects the document root (which is always the
parent of the document element)"

So say your xml looks like:
<root>
  <foo> ... </foo>
  <bar> ... </bar>
</root>

What you are asking for is equivalent to saying, I want the
@myRootAttribute of the parent of root.

What I think you mean to say is:

<xsl:template match="/root/@myRootAttribute"/>

which would match the attribute below in the root element.

<root @myRootAttribute="spiffy">
   <foo>...</foo>
</root>

Of course, this more involved if by the root attribute you actually
mean the namespace that is declared there.  Is this the case?

Jonathan Gorman

Current Thread