[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

design question on function namespaces

Subject: design question on function namespaces
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Tue, 3 May 2005 07:16:19 -0400
xsl declare function
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.