Guest User

Untitled

a guest
Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <root>
  3. <isSequence>
  4. <seq name="a" value="1, 2, 3"/>
  5. <seq name="b" value="3, 1, 5, 6"/>
  6. <seq name="c" value="15, 16, 18, 0"/>
  7. <seq name="d" value="21, 22, 23, 24, 25"/>
  8. <seq name="e" value="A, B, C"/>
  9. </isSequence>
  10. </root>
  11.  
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  15. exclude-result-prefixes="xs"
  16. version="2.0">
  17. <xsl:template match="/">
  18. <xsl:for-each select="root/isSequence/seq">
  19. <xsl:if test="subsequence(@value, 0)">
  20. <xsl:value-of select="@name"/> is an ascending numeric sequence
  21. </xsl:if>
  22. </xsl:for-each>
  23. </xsl:template>
  24. </xsl:stylesheet>
  25.  
  26. a is an ascending numeric sequence
  27. d is an ascending numeric sequence
  28.  
  29. <xsl:template match="seq[let $items := tokenize(@value, ',s+')!xs:integer(.) return every $p in 1 to count($items) satisfies $items[$p] = $items[1] + ($p - 1)]">
  30. <xsl:value-of select="@name"/><xsl:text> is an ascending numeric sequence
  31. </xsl:text>
  32. </xsl:template>
  33.  
  34. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  35. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  36. exclude-result-prefixes="#all"
  37. expand-text="yes"
  38. version="3.0">
  39.  
  40. <xsl:mode on-no-match="shallow-skip"/>
  41. <xsl:strip-space elements="*"/>
  42.  
  43. <xsl:output method="text"/>
  44.  
  45. <xsl:template match="seq[let $items := tokenize(@value, ',s+')!xs:integer(.) return every $p in 1 to count($items) satisfies $items[$p] = $items[1] + ($p - 1)]">
  46. <xsl:value-of select="@name"/><xsl:text> is an ascending numeric sequence
  47. </xsl:text>
  48. </xsl:template>
  49.  
  50. </xsl:stylesheet>
Add Comment
Please, Sign In to add comment