|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: design question on function namespaces
> Yes, I understand this. But say you want to implement a function for > your "does this chapter have any footnotes" example, but you > deal with > DocBook NG, TEI 5 and OpenOffice. Would you reimplement the function > three times, or would there be a way to make it generic so that it > could be reused across the different document types and > namespaces. If > you do the former, then they're not THAT reusable. > If the implementation in the three cases is completely different, but you want the user to make the same call in each case, then you need to implement the polymorphism yourself behind a wrapper interface. Of course polymorphism in XSLT means apply-templates... So you could define function name="doc:chapter-has-footnotes" xsl:param name="chapter" xsl:apply-templates select="chapter" mode="doc:chapter-has-footnotes" /function and then implement a template in this mode for each of the different document types It's easy to forget that in 2.0 a template can return a boolean: <xsl:template match="open-office:chapter" mode="doc:chapter-has-footnotes" as="xs:boolean"> <xsl:sequence select="exists(.//footnote)"/> </xsl:template> Just a thought, there are many ways to organise this. Michael Kay http://www.saxonica.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
|

Cart








