xsltは初めてで、質問があります。
必要なすべてのセッターとゲッターを含む検証クラスがあります。たとえば、次のような方法があります。
public void setProducer(String producer) {
this.producer = producer;
System.out.println("TEST");
}
アプリを起動すると、このメソッドが呼び出されていないことがわかります。
xslファイルに次のようなコードを追加すると、コンソールにテストメッセージのみが表示されます。
<xsl:value-of name="producerName" />
では、最初の使用時に私の間違いまたはxsl:variableはどこで初期化されますか?
私はこのコードを持っています:
<xsl:param name="category-name" />
<xsl:param name="subcategory-name" />
<xsl:param name="producer" />
<xsl:param name="model" />
<xsl:param name="color" />
<xsl:param name="date_of_issue" />
<xsl:param name="price" />
<xsl:param name="not_in_stock" />
<xsl:variable name="validator" select="validation:new()" />
<xsl:template match="/">
<xsl:for-each select="products/category">
<xsl:if test="name() = 'category' and @name=$category-name">
<xsl:apply-templates select="subcategory[@name=$subcategory-name]" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="subcategory">
<xsl:apply-templates select="good" />
<xsl:variable name="errorSize"
select="validation:getErrorListSize($validator)" />
<xsl:if test="$errorSize = 0">
<xsl:variable name="producerName"
select="validation:setProducer($validator, $producer)" />
<xsl:variable name="setModel"
select="validation:setModel($validator, $model)" />
<xsl:variable name="setColor"
select="validation:setColor($validator, $color)" />
<xsl:variable name="setDateOfIssue"
select="validation:setDateOfIssue($validator, $date_of_issue)" />
<xsl:if test="$not_in_stock != null">
<xsl:variable name="setPrice"
select="validation:setPrice($validator, $price)" />
</xsl:if>
<xsl:variable name="validationResult"
select="validation:validateAllFields($validator)" />
VALIDATION FINISHED
<xsl:variable name="errors"
select="validation:getErrorListSize($validator)" />
<xsl:value-of select="$errors"/>
</xsl:if>
<xsl:if test="$errorSize != 0">
REDIRECT. ERROR EXISTS
</xsl:if>
</xsl:template>