Solved

XPath and XQuery: fn:xxx

Posted on 2015-01-21
1
135 Views
Last Modified: 2015-01-21
XPath and XQuery: fn:xxx

What exactly are the group of functions with a prefix of "fn:".

How are they different than something like format-number()

Is there a fn:xxx equivalent to format-number() ?

Thnkas
0
Comment
Question by:Anthony Lucia
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 40563297
basically you will see the fn: used in books and web examples,
I never use them in my code
fn: indicates the namespace xmlns:fn="http://www.w3.org/2005/xpath-functions"
the namespace of the functions internaly defined in the XPath spec
but if you use the prefix, you also have to declare the prefix this way
xmlns:fn="http://www.w3.org/2005/xpath-functions"

eg.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/">
        <xsl:value-of select="fn:abs(5)"></xsl:value-of>
    </xsl:template>
</xsl:stylesheet>

Open in new window


I simply use it without the prefix, for me that is much clearer
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/">
        <xsl:value-of select="abs(5)"></xsl:value-of>
    </xsl:template>
</xsl:stylesheet>

Open in new window


You can not declare functions yourself in that namespace, so your own functions will always need to be prefixed
so the distinction is easy
(I think an early XPath recommendation draft had the fn: as mandatory for XPath functionsn but the requirement was dropped)

Anyhow, simply forget about fn:, they are the same
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now