[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Disjunctive reasoning in XSLT: controlling presen
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|