Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. <xsl:template match="div[contains(@class, 'pfg-form')]//form">
  2. <form>
  3. <xsl:copy-of select="attribute::*[not(name()='class')]" />
  4. <xsl:attribute name="class">
  5. <xsl:value-of select="@class" /> form-horizontal
  6. <xsl:if test="@class[contains(., 'formid-formular-test')]"> form-test container</xsl:if></xsl:attribute>
  7. <xsl:attribute name="id">pfg-form</xsl:attribute>
  8. <xsl:apply-templates />
  9. </form>
  10. </xsl:template>
  11. <xsl:template match="div[contains(@class, 'pfg-form')]//div[contains(@class, 'field')]">
  12. <xsl:for-each select=".">
  13. <xsl:variable name="error">
  14. <xsl:choose>
  15. <xsl:when test="contains(@class, 'error')"> error</xsl:when>
  16. </xsl:choose>
  17. </xsl:variable>
  18. <xsl:variable name="help-text">
  19. <xsl:copy-of select=".//*[contains(@class, 'formHelp')]/text()" />
  20. </xsl:variable>
  21. <div class="form-group {$error}">
  22. <label>
  23. <xsl:copy-of select="attribute::*[not(name()='class')]" />
  24. <xsl:attribute name="class">col-sm-2</xsl:attribute>
  25. <xsl:copy-of select=".//*[contains(@class, 'formQuestion')]/text()" />
  26. <span class="formHelp" data-tooltip="{$help-text}"></span>
  27. </label>
  28. <div class="col-sm-4">
  29. <xsl:choose>
  30. <xsl:when test=".//input[@type='text' or @type='password']">
  31. <input>
  32. <xsl:copy-of select=".//input/@*" />
  33. <xsl:attribute name="class">
  34. <xsl:value-of select="./input/@class" /> form-control</xsl:attribute>
  35. </input>
  36. </xsl:when>
  37. <xsl:when test=".//input[@type='radio']">
  38. <xsl:for-each select="./span/input[@type='radio']">
  39. <label class="radio-inline">
  40. <input>
  41. <xsl:copy-of select="@*" />
  42. </input>
  43. <!--xsl:value-of select="./preceding-sibling::*[1]" /-->
  44. <xsl:value-of select="following::label/text()" />
  45. </label>
  46. </xsl:for-each>
  47. </xsl:when>
  48. <xsl:when test=".//input[@type='checkbox']">
  49. <xsl:for-each select=".//input">
  50. <input>
  51. <xsl:copy-of select="@*" />
  52. </input>
  53. </xsl:for-each>
  54. </xsl:when>
  55. <xsl:when test="./select">
  56. <select>
  57. <xsl:copy-of select="./select/@*" />
  58. <xsl:attribute name="class">
  59. <xsl:value-of select="./select/@class" /> form-control</xsl:attribute>
  60. <xsl:for-each select="./select/option">
  61. <option value="{@value}">
  62. <xsl:value-of select="text()" />
  63. </option>
  64. </xsl:for-each>
  65. </select>
  66. </xsl:when>
  67. <xsl:when test="./textarea">
  68. <textarea>
  69. <xsl:copy-of select="./textarea/@*" />
  70. <xsl:attribute name="class">
  71. <xsl:value-of select="@class" /> form-control</xsl:attribute>
  72. </textarea>
  73. </xsl:when>
  74. <xsl:when test="contains(@class, 'PFG-RichLabel')">
  75. <xsl:copy-of select="./*" />
  76. </xsl:when>
  77. </xsl:choose>
  78. <!--xsl:apply-templates select="./input | ./textarea | ./select">
  79. <xsl:copy-of select=".">
  80. <xsl:attribute name="class"><xsl:value-of select="@class" /> form-control</xsl:attribute>
  81. </xsl:copy>
  82. </xsl:apply-templates-->
  83. <div class="fieldErrorBox">
  84. <xsl:copy-of select="./div[contains(@class, 'fieldErrorBox')]/text()" />
  85. </div>
  86. </div>
  87. <!--xsl:copy>
  88. <xsl:apply-templates select="node()|@*"/>
  89. </xsl:copy-->
  90. </div>
  91. </xsl:for-each>
  92. </xsl:template>
  93. <xsl:template match="div[contains(@class, 'pfg-form')]//form//fieldset">
  94. <xsl:for-each select=".">
  95. <fieldset>
  96. <xsl:copy-of select="@*" />
  97. <xsl:attribute name="class">
  98. <xsl:value-of select="@class" />
  99. </xsl:attribute>
  100. <xsl:apply-templates />
  101. </fieldset>
  102. </xsl:for-each>
  103. </xsl:template>
  104. <xsl:template match="div[contains(@class, 'pfg-form')]//div[contains(@class,'formHelp')]">
  105. <xsl:for-each select=".">
  106. <p>
  107. <xsl:attribute name="class">
  108. <xsl:value-of select="@class" /> help-block description</xsl:attribute>
  109. <xsl:copy-of select="./text()" />
  110. </p>
  111. </xsl:for-each>
  112. </xsl:template>
  113. <xsl:template match="//input[@type[contains(., 'submit') or contains(., 'button')]]">
  114. <button type="button">
  115. <xsl:copy-of select="attribute::*[not(name()='class')]" />
  116. <xsl:attribute name="class">
  117. <xsl:value-of select="@class" /> btn
  118. <xsl:if test="@name[contains(., 'delete') or contains(., 'Remove')]">btn-danger</xsl:if><xsl:if test="@name[contains(., 'form_submit') or contains(., 'Save') or contains(., 'RenameAll')]">btn-primary btn-slash outline inverted btn-icon-paperflyer</xsl:if><xsl:if test="@name[contains(., 'delete') or contains(., 'Remove')]">btn-danger</xsl:if></xsl:attribute>
  119. <xsl:value-of select="./@value" />
  120. </button>
  121. </xsl:template>
  122. <xsl:template match="//div[@id[contains(.,'parent-fieldname-formPrologue') or contains(.,'parent-fieldname-formEpilogue')]]">
  123. <xsl:variable name="container">
  124. <xsl:choose>
  125. <xsl:when test="contains(./@id,'formPrologue')">form-prologue</xsl:when>
  126. <xsl:when test="contains(./@id,'formEpilogue')">form-epilogue</xsl:when>
  127. </xsl:choose>
  128. </xsl:variable>
  129. <div id="{$container}">
  130. <xsl:copy-of select="." />
  131. </div>
  132. </xsl:template>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement