Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <xsl:for-each select="tokenize(Path,'.')">
  2. <xsl:choose>
  3. <xsl:when test="position() = 1 and position() = last()">SITE = '<xsl:value-of select="."/>' AND PATH = ''</xsl:when>
  4. <xsl:when test="position() = 1 and position() != last()">SITE = '<xsl:value-of select="."/>' </xsl:when>
  5. <xsl:when test="position() = 2 and position() = last()">AND PATH = '<xsl:value-of select="."/>' </xsl:when>
  6. <xsl:when test="position() = 2">AND PATH = '<xsl:value-of select="."/></xsl:when>
  7. <xsl:when test="position() > 2 and position() != last()">.<xsl:value-of select="."/></xsl:when>
  8. <xsl:when test="position() > 2 and position() = last()">.<xsl:value-of select="."/>' </xsl:when>
  9. <xsl:otherwise>zxyarglfaux</xsl:otherwise>
  10. </xsl:choose>
  11. </xsl:for-each>
  12.  
  13. INPUT: North OUTPUT: SITE = 'North' AND PATH = ''
  14. INPUT: North.A OUTPUT: SITE = 'North' AND PATH = 'A'
  15. INPUT: North.A.B OUTPUT: SITE = 'North' AND PATH = 'A.B'
  16. INPUT: North.A.B.C OUTPUT: SITE = 'North' AND PATH = 'A.B.C'
  17.  
  18. <xsl:text>Site = '</xsl:text>
  19. <xsl:value-of select="substring-before(Path,'.')"/>
  20. <xsl:text>' AND PATH = '</xsl:text>
  21. <xsl:value-of select="substring-after(Path,'.')"/>
  22. <xsl:text>'</xsl:text>
  23.  
  24. <xsl:text>SITE = '</xsl:text>
  25. <xsl:choose>
  26. <xsl:when test="contains($Path, '.')>
  27. <xsl:value-of select="substring-before($Path, '.')"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:value-of select="$Path"/>
  31. </xsl:otherwise>
  32. </xsl:choose>
  33. <xsl:text>' AND PATH = '</xsl:text>
  34. <xsl:value-of select="substring-after($Path, '.')"/>
  35. <xsl:text>'</xsl:text>
  36.  
  37. <xsl:value-of select="string-join( 'SITE = ', substring-before(concat(Path,'.'),'.'),
  38. ' AND PATH = ', substring-after(Path,'.'), ' '), '''')" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement