Solved

XPath and XQuery: fn:xxx

Posted on 2015-01-21
1
142 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

820 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