xsl-list
[Top] [All Lists]

Re: Copying a document except specific root attribute

2005-06-13 08:24:57
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--