Ken,
This works fine. The difficulty arises from the fact that the input
data (a given row) can be quite variable: An auto policy might have one
driver, or five, might cover one vehicle or 7, there might be no prior
accidents or violations, or several, etc., etc. The naive transform
that I currently generate takes an expansive approach, setting up XML
subtrees for most everything that might possibly be coming through in
the data. This has the effect of leaving essentially empty subtrees
throughout the target ACORD tree, which is not acceptable. I currently
perform a post-process tree walk to clean up. However, I'd like to
understand if it is possible to more intelligently generate an XSLT
transform which can omit various subtrees when the data for them is not
present.
I don't think you should be particularly wary of using a multi-step
process: using pipelines means the individual transformations are a lot
simpler, easier to maintain and debug.
But if you wanted to do it one pass, what about putting the prospective
children of an element in a variable and only creating the element if
the variable actually holds something? The templates you generate would
look something like:
<xsl:template match="colname">
<xsl:variable name="children" as="element()*">
<!-- Code for generating the children goes here -->
</xsl:variable>
<xsl:if test="exists($children)">
<newElement>
<xsl:sequence select="$children" />
</newElement>
</xsl:if>
</xsl:template>
Cheers,
Jeni
--
Jeni Tennison
http://www.jenitennison.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>
--~--