Solved

XPath and XQuery: fn:xxx

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

706 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

19 Experts available now in Live!

Get 1:1 Help Now