Guest User

Untitled

a guest
May 14th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. xslt variable strangness
  2. <a><xsl:copy-of select="(@attrib|exsl:node-set(0))"/></a>
  3. <b><xsl:copy-of select="(@attrib|exsl:node-set(0))[position()=1]"/></b>
  4.  
  5. <x><xsl:copy-of select="(@attrib|exsl:node-set(0))[1]"/></x>
  6. <xsl:variable name="value" select="@attrib"/>
  7. <y><xsl:copy-of select="($value|exsl:node-set(0))[1]"/></y>
  8.  
  9. <a attrib="1">0</a>
  10. <b attrib="1"/>
  11.  
  12. <x>0</x>
  13. <y attrib="1"/>
  14.  
  15. concat(@attrib,
  16. substring(0, 2 -not(@attrib))
  17. )
  18.  
  19. <xsl:stylesheet version="1.0"
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  21. <xsl:output omit-xml-declaration="yes" indent="yes"/>
  22.  
  23. <xsl:template match="x">
  24. <xsl:value-of select=
  25. "concat(@attrib,
  26. substring('0', 2 -not(@attrib))
  27. )"/>
  28.  
  29. ==========
  30. </xsl:template>
  31. </xsl:stylesheet>
  32.  
  33. <t>
  34. <x attrib="abc"/>
  35. <x/>
  36. </t>
  37.  
  38. abc
  39.  
  40. ==========
  41.  
  42. 0
  43.  
  44. ==========
Advertisement
Add Comment
Please, Sign In to add comment