?
Solved

XPath and XQuery: fn:xxx

Posted on 2015-01-21
1
Medium Priority
?
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 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