code_junkie

XSLT selecting attribute of ancestor; &ldquo;../..&rdquo; works, &ldquo;ancestor::<tagname>&rdquo; doesn't

Nov 12th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <package name="blork!" xmlns="http://xml.snapin.com/XBL">
  2. <xsl:template name="doSomething">
  3. <tokens>
  4. <token name="text-from-resource" export="public" />
  5. </tokens>
  6. </xsl:template>
  7. </package>
  8.  
  9. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s4="http://xml.snapin.com/XBL">
  10. <xsl:template match="/">
  11. <xsl:if test="count(//s4:token) >0">
  12. <xsl:text>Tokens!</xsl:text>
  13. <xsl:for-each select="//s4:token">
  14. <xsl:choose>
  15. <xsl:when test="@export='global'" />
  16. <xsl:otherwise>
  17. <xsl:value-of select="translate(ancestor::s4:package/@name,$uc,$lc)" />
  18. </xsl:otherwise>
  19. </xsl:choose>
  20. </xsl:for-each>
  21. </xsl:if>
  22. </xsl:template>
  23. </xsl:stylesheet>
  24.  
  25. <xsl:value-of select="translate(ancestor::s4:package/@name,$uc,$lc)" />
  26.  
  27. <xsl:value-of select="translate(ancestor::*[local-name()='package']/@name,$uc,$lc)" />
Add Comment
Please, Sign In to add comment