View Single Post
  #5 (permalink)  
Old September 6th, 2011, 06:27 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

OK, so you want to include the namespace at the article level if and only if it is use somewhere (at any depth) within the article? It's not really necessary to be so fussy about where the namespace declarations go, but it you are you can do it.

Code:
<xsl:template match="article">
  <article>
    <xsl:if test=".//@*[starts-with(name(), 'xlink:')]">
      <xsl:copy-of select="namespace::xlink"/>
    </xsl:if>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote