|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Multiple views on an xml document
Consider the following xml document:
<stocks>
<stock>
<symbol>IBM</symbol>
<desc></desc>
</stock>
</stocks>
Now consider the problem of generating two html views on it: a summary
view (showing only symbol) and a detailed view (showing both symbol and
desc.) The decision about which view to generate is based on a parameter
in the principle xsl stylesheet, something like
<xsl:import href="summary-view.xsl"/>
<xsl:import href="detailed-view.xsl"/>
<xsl:param name="show-details"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$show-details='yes'">
<!-- generate detailed view -->
</xsl:when>
<xsl:otherwise>
<!-- generate summary view -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
One approach would be to call named templates show-detailed-view or
show-summary-view as the case may be, but that willn't work if the
both implementations require templates that match on "stock". As
presented, templates that match on "stock" imported through
"summary-view.xsl" will have precedence over the ones imported through
"detailed-view.xsl".
Another approach that does work is to define templates with "summary" and
"detailed" modes. It should also be possible to use predicates in the
summary and detailed templates based on the "show-details" parameter. But
I'm convinced I must be missing something. Does anyone have any insights
into a nice elegent solution to this class of problems?
Regards,
Daniel Parker
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








