Guest User

Untitled

a guest
Jan 21st, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <xsl:template
  2. match="//*[contains(@*:default,'instance(''document'')/')
  3. mode="pass">
  4.  
  5. <xsl:variable
  6. name="regex"
  7. as="element()*">
  8. <regex>instance('document')/doc_type/description</regex>
  9. <regex>anotherRegex</regex>
  10. </xsl:variable>
  11.  
  12. <xsl:variable
  13. name="replacement"
  14. as="element()*">
  15. <replacement>xxf:get-request-parameter('documentDesc')</replacement>
  16. <replacement>replacedRegex</replacement>
  17. </xsl:variable>
  18.  
  19. <xsl:element name="{name()}">
  20. <xsl:for-each select="@*">
  21. <xsl:choose>
  22. <xsl:when test="name() = ('xxf:default')">
  23. <xsl:attribute name="xxf:default">
  24. <xsl:analyze-string
  25. regex="{concat('(',$regex[1],'|',$regex[2],')')}"
  26. select=".">
  27. <xsl:matching-substring>
  28. <xsl:if test="matches(.,$regex[1])">
  29. <xsl:value-of select="replace(.,$regex[1],$replacement[1])" />
  30. </xsl:if>
  31. <xsl:if test="matches(.,$regex[2])">
  32. <xsl:value-of select="replace(.,$regex[2],$replacement[2])" />
  33. </xsl:if>
  34. </xsl:matching-substring>
  35. <xsl:non-matching-substring>
  36. <xsl:value-of select="." />
  37. </xsl:non-matching-substring>
  38. </xsl:analyze-string>
  39. </xsl:attribute>
  40. </xsl:when>
  41. <xsl:otherwise>
  42. <xsl:attribute name="{local-name()}"><xsl:value-of select="." /></xsl:attribute>
  43. </xsl:otherwise>
  44. </xsl:choose>
  45. </xsl:for-each>
  46. </xsl:element>
  47. </xsl:template>
  48.  
  49. <xf:bind id="clinic-bind"
  50. name="clinic"
  51. xxf:default="instance('document')/doc_type/description"
  52. type="xf:string"/>
  53.  
  54. <xf:bind id="clinic-bind"
  55. name="clinic"
  56. xxf:default="xxf:get-request-parameter('documentDesc')"
  57. type="xf:string"/>
Add Comment
Please, Sign In to add comment