创建元素时,我需要将更改值添加到data-id属性(正在工作),但是一旦设置了此值,我需要保存它。问题是,如果在创建表单期间更改了任何顺序,则ID将会更改,并且对于data-id我需要一个固定值。有任何想法吗。XSL - 如果值不存在,则将值添加到属性
我有用于创建输入元件这样的代码:
<div class="field" align="left">
<xsl:element name="input">
<xsl:attribute name="id"><xsl:value-of select="$field_id" /></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="$field_id" /></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="." /></xsl:attribute>
<xsl:attribute name="maxlength"><xsl:value-of select="@maxlength" /></xsl:attribute>
<xsl:attribute name="minlength"><xsl:value-of select="@minlength" /></xsl:attribute>
<xsl:attribute name="class">text</xsl:attribute>
<xsl:attribute name="data-id">
<xsl:value-of select="$field_id" />
</xsl:attribute>
<xsl:attribute name="required">
<xsl:choose>
<xsl:when test="@required='required'">required</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="onchange">
fieldPropertyChange('smalltext', '<xsl:value-of select="$field_id" />');
</xsl:attribute>
</xsl:element>
感谢您的深刻见解:)。我没有制作xls代码,有点继承它,现在我们无法改变它,所以我有了几乎4k行纯粹的混沌。 – Sasha
有乐趣清理混乱。 :)顺便说一句,你可以编写XSL模板来重写你的XSL模板。就像一个想法。如果你的输入XSL是重复的,那将是清理它的一种方法。 – Tomalak