Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <xsl:template match="div[contains(@class, 'pfg-form')]//form">
- <form>
- <xsl:copy-of select="attribute::*[not(name()='class')]" />
- <xsl:attribute name="class">
- <xsl:value-of select="@class" /> form-horizontal
- <xsl:if test="@class[contains(., 'formid-formular-test')]"> form-test container</xsl:if></xsl:attribute>
- <xsl:attribute name="id">pfg-form</xsl:attribute>
- <xsl:apply-templates />
- </form>
- </xsl:template>
- <xsl:template match="div[contains(@class, 'pfg-form')]//div[contains(@class, 'field')]">
- <xsl:for-each select=".">
- <xsl:variable name="error">
- <xsl:choose>
- <xsl:when test="contains(@class, 'error')"> error</xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="help-text">
- <xsl:copy-of select=".//*[contains(@class, 'formHelp')]/text()" />
- </xsl:variable>
- <div class="form-group {$error}">
- <label>
- <xsl:copy-of select="attribute::*[not(name()='class')]" />
- <xsl:attribute name="class">col-sm-2</xsl:attribute>
- <xsl:copy-of select=".//*[contains(@class, 'formQuestion')]/text()" />
- <span class="formHelp" data-tooltip="{$help-text}"></span>
- </label>
- <div class="col-sm-4">
- <xsl:choose>
- <xsl:when test=".//input[@type='text' or @type='password']">
- <input>
- <xsl:copy-of select=".//input/@*" />
- <xsl:attribute name="class">
- <xsl:value-of select="./input/@class" /> form-control</xsl:attribute>
- </input>
- </xsl:when>
- <xsl:when test=".//input[@type='radio']">
- <xsl:for-each select="./span/input[@type='radio']">
- <label class="radio-inline">
- <input>
- <xsl:copy-of select="@*" />
- </input>
- <!--xsl:value-of select="./preceding-sibling::*[1]" /-->
- <xsl:value-of select="following::label/text()" />
- </label>
- </xsl:for-each>
- </xsl:when>
- <xsl:when test=".//input[@type='checkbox']">
- <xsl:for-each select=".//input">
- <input>
- <xsl:copy-of select="@*" />
- </input>
- </xsl:for-each>
- </xsl:when>
- <xsl:when test="./select">
- <select>
- <xsl:copy-of select="./select/@*" />
- <xsl:attribute name="class">
- <xsl:value-of select="./select/@class" /> form-control</xsl:attribute>
- <xsl:for-each select="./select/option">
- <option value="{@value}">
- <xsl:value-of select="text()" />
- </option>
- </xsl:for-each>
- </select>
- </xsl:when>
- <xsl:when test="./textarea">
- <textarea>
- <xsl:copy-of select="./textarea/@*" />
- <xsl:attribute name="class">
- <xsl:value-of select="@class" /> form-control</xsl:attribute>
- </textarea>
- </xsl:when>
- <xsl:when test="contains(@class, 'PFG-RichLabel')">
- <xsl:copy-of select="./*" />
- </xsl:when>
- </xsl:choose>
- <!--xsl:apply-templates select="./input | ./textarea | ./select">
- <xsl:copy-of select=".">
- <xsl:attribute name="class"><xsl:value-of select="@class" /> form-control</xsl:attribute>
- </xsl:copy>
- </xsl:apply-templates-->
- <div class="fieldErrorBox">
- <xsl:copy-of select="./div[contains(@class, 'fieldErrorBox')]/text()" />
- </div>
- </div>
- <!--xsl:copy>
- <xsl:apply-templates select="node()|@*"/>
- </xsl:copy-->
- </div>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="div[contains(@class, 'pfg-form')]//form//fieldset">
- <xsl:for-each select=".">
- <fieldset>
- <xsl:copy-of select="@*" />
- <xsl:attribute name="class">
- <xsl:value-of select="@class" />
- </xsl:attribute>
- <xsl:apply-templates />
- </fieldset>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="div[contains(@class, 'pfg-form')]//div[contains(@class,'formHelp')]">
- <xsl:for-each select=".">
- <p>
- <xsl:attribute name="class">
- <xsl:value-of select="@class" /> help-block description</xsl:attribute>
- <xsl:copy-of select="./text()" />
- </p>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="//input[@type[contains(., 'submit') or contains(., 'button')]]">
- <button type="button">
- <xsl:copy-of select="attribute::*[not(name()='class')]" />
- <xsl:attribute name="class">
- <xsl:value-of select="@class" /> btn
- <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>
- <xsl:value-of select="./@value" />
- </button>
- </xsl:template>
- <xsl:template match="//div[@id[contains(.,'parent-fieldname-formPrologue') or contains(.,'parent-fieldname-formEpilogue')]]">
- <xsl:variable name="container">
- <xsl:choose>
- <xsl:when test="contains(./@id,'formPrologue')">form-prologue</xsl:when>
- <xsl:when test="contains(./@id,'formEpilogue')">form-epilogue</xsl:when>
- </xsl:choose>
- </xsl:variable>
- <div id="{$container}">
- <xsl:copy-of select="." />
- </div>
- </xsl:template>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement