Advertisement
Guest User

Untitled

a guest
May 29th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <xsl:if test="string-contains(//ns0:elem/value, 'sth')">
  2.  
  3.  
  4. </xsl:if>
  5.  
  6. <xsl:variable name="alpha"
  7. select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  8. <xsl:if test="string-length(translate(., $alpha, '')) > 0">
  9. <!-- context node contains non-alpha characters -->
  10. </xsl:if>
  11.  
  12. <xsl:if test="translate(., $alpha, '')">
  13.  
  14. <xsl:if test="translate(., translate(., $alpha, ''), '')">
  15. <!-- context-node contains characters on the blacklist (in $alpha) -->
  16. </xsl:if>
  17.  
  18. not(string-length(translate(., $alpha, ''))=string-length())
  19.  
  20. <xsl:if test="translate(., $alpha, '')">
  21. [contains some characters not on the list]
  22. </xsl:if>
  23. <xsl:if test="not(translate(., $alpha, ''))">
  24. [contains only characters on the list]
  25. </xsl:if>
  26. <xsl:if test="translate(., translate(., $alpha, ''), '')">
  27. [contains some characters on the list]
  28. </xsl:if>
  29. <xsl:if test="not(translate(., translate(., $alpha, ''), ''))">
  30. [contains only characters not on the list]
  31. </xsl:if>
  32.  
  33. translate(., translate(., $vAlpha, ''), '')
  34.  
  35. string-length(translate($str, $vAlpha, '')) = 0
  36.  
  37. <xsl:stylesheet version="1.0"
  38. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  39. <xsl:output method="text"/>
  40.  
  41. <xsl:variable name="vUpper" select=
  42. "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  43.  
  44. <xsl:variable name="vLower" select=
  45. "'abcdefghijklmnopqrstuvwxyz'"/>
  46.  
  47. <xsl:variable name="vAlpha" select=
  48. "concat($vUpper, $vLower)"/>
  49.  
  50. <xsl:variable name="vStr" select="'A12B_..c02d'"/>
  51.  
  52. <xsl:template match="/">
  53. <xsl:value-of select=
  54. "translate($vStr,
  55. translate($vStr, $vAlpha, ''), '')
  56. "/>
  57.  
  58.  
  59. The string <xsl:value-of select="$vStr"/> has <xsl:text/>
  60. <xsl:value-of select=
  61. "string-length(translate($vStr, $vAlpha, ''))"/> <xsl:text/>
  62. non-letters
  63.  
  64. </xsl:template>
  65. </xsl:stylesheet>
  66.  
  67. ABcd
  68.  
  69.  
  70. The string A12B_..c02d has 7
  71. non-letters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement