[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] design question on function namespaces
I've modiified a lot of my code and moved much of the logic into
functions. For example:
<xsl:function name="mods:year"> <xsl:param name="bibref" as="element(mods:mods)"/> <xsl:for-each select="$bibref"> <xsl:value-of select="substring((mods:originInfo/mods:dateIssued, mods:relatedItem/mods:originInfo/mods:dateIssued, mods:relatedItem/mods:part/mods:date)[1],1,4)" /> </xsl:for-each> </xsl:function> Because XSLT 2.0 and XQuery share the same data model (XPath 2.0), it's easy to convert between them. Here's the equivalent function in the eXist XML DB bibliographic example (which I use; I modified this function to match the logic of my XSLT one): declare function display:year($rec as element()) as xs:string? { substring(($rec/mods:originInfo/mods:dateIssued, $rec/mods:relatedItem/mods:originInfo/mods:dateIssued, $rec/mods:relatedItem/mods:part/mods:date)[1],1,4) }; I think based on this, I'm going to try where possible to have logic defined in functions, and in xpath (2.0) rather than pure XSLT. One design question: Mike Kay in his book on XSLT 2.0 advocates function namespaces based on the namespace of the data they work on. I ask because I'd like to keep the option open later to support formats in other namespaces. So does this suggest using a namespace that refers to the function rather than the input namespace? Bruce
|
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
|