This is a coding style question.
My document looks like this:
<xfixture>
<bench>
<fixture class="com.agtrz.test.StringReverse">
<control-point name="input"
class="java.lang.String"/>
<control-point name="output"
trim="true"
class="java.lang.String"/>
</fixture>
<test>
<control name="input">Hello</control>
<control name="output" trim="false">olleH</control>
</test>
</bench>
</xfixture>
I'm using this document to generate JUnit tests.
I run the document through two XSLT _2.0_ transforms. The first
one "expands" the document, which makes it easier to write a
transform that generates Java code.
When I expand, I want to copy properties from the control
definiton, into the test control value, unless they have been
overridden by the
<xfixture>
<bench>
<fixture class="com.agtrz.test.StringReverse">
<control-point name="input"
class="java.lang.String"/>
<control-point name="output"
class="java.lang.String"/>
</fixture>
<test>
<control class="java.lang.String" name="input">Hello</control>
<control trim="false"
class="java.lang.String" name="output">olleH</control>
</test>
</bench>
</xfixture>
In my expand.xslt I have a template like so...
<xsl:template match="control">
<xsl:variable name="definition"
select="ancestor::bench/fixture/control-point[
@name = current()/@name]"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="not(@trim)">
<xsl:copy-of select="$defition/@trim"/>
</xsl:if>
<xsl:if test="not(@class)">
<xsl:copy-of select="$defition/@class"/>
</xsl:if>
<!--| Repeat for every attribute I add. |-->
</xsl:copy>
</xsl:template>
My question... Is there a clever select statement that could
"copy all the attributes, and all the definition attributes,
unless they are already definied in the test instance."
--
Alan Gutierrez - alan(_at_)engrm(_dot_)com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--