Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XPath and XQuery: fn:xxx

Posted on 2015-01-21
1
Medium Priority
?
157 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…
Suggested Courses

610 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