[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

XPath/XQuery equivalent of xsl:number?

Adam Retter adam.retter at googlemail.com
Thu Nov 17 11:23:41 PST 2011


  XPath/XQuery equivalent of xsl:number?
Joe,

In eXist-db (which I happen to know you are using), if you want the
format-number function, you can just call - xsl:format-number(...)
from XQuery, see the signature for in the eXist-db function guide -
xsl:format-number($number as numeric?, $format as xs:string) xs:string

However I doubt format-number function is actually what you want as it
doesnt appear to support roman numerals. As such I think Ken's example
is a good start

On 17 November 2011 19:04, Joe Wicentowski <http://x-query.com/mailman/listinfo/talk> wrote:
> Hi all,
>
> I am constructing a table of contents based on a TEI document (whose
> structure consists primarily of nested divs), and would like to be
> able to generate appropriate heading levels for each the table of
> contents hierarchy.  Specifically, I want to be able to generate the
> "I", "II", "A", "B", and "a" bits in:
>
> I. Chapter 1
> II. Chapter 2
>  A. Section 1
>  B. Section 2
>    a) Subsection 1
>
> Put another way, borrowing from CSS terminology, I need to be able to
> format an integer as "upper-roman", "upper-alpha", and "lower-alpha."
>
> Borrowing from XSL terminology, I need to perform the equivalent
> function of <xsl:number>, as in:
>
>  <xsl:number value="2" format="I'/> ==> returns "II"
>  <xsl:number value="2" format="a'/> ==> returns "b"
>  <xsl:number value="2" format="A'/> ==> returns "B"
>
> I think what I really need is XPath 3.0's fn:format-integer()
> function[1], but it appears that XPath 3.0 is still at the Working
> Draft stage.
>
> So my question: Of course I could hack my own format-integer()
> function together (indeed, my current kludge is to pipe out my
> integers to an XSL stylesheet), but is there an XPath or XQuery
> library that would let me do this?
>
> Thanks,
> Joe
>
> [1] http://www.w3.org/TR/xpath-functions-30/#func-format-integer
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk
>



-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk



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-2011 All Rights Reserved.