• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XQuery support

Community Beginner ,
Nov 08, 2006 Nov 08, 2006

Copy link to clipboard

Copied

Does CFMX7 support XQuery?
TOPICS
Advanced techniques

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Nov 15, 2006 Nov 15, 2006


Success! I needed to use AS to name the return as a CF variable when using XQuery. For SQL, the Colunm name can be used without being identified

The table is HAFDIR
The column is Article
The root element of the xml is also Article (refered to as /Article below)

the following XQuery statement worked within cfquery:

SELECT
Article.query ('declare default namespace "foobar';
(/Article)')
AS 'thing'
FROM dbo.HAFDIR


The cfoutput section refers to the output as #thing#

e.g.

<cfoutput>
...

Votes

Translate

Translate
Advisor ,
Nov 08, 2006 Nov 08, 2006

Copy link to clipboard

Copied

Not yet, not directly.

You can use the Saxon parser via Java to work with XQuery.

Figure it out and post some code!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2006 Nov 08, 2006

Copy link to clipboard

Copied



Thank you. Are there any plans to include XQuery support in the near future? This is basic for use with SQL Server 2005, Oracle etc. I would rather have Macromedia do the development and debugging. Otherwise, why use CF?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 08, 2006 Nov 08, 2006

Copy link to clipboard

Copied

I've seen no reports of people claiming Xquery support in CF8 ("Scorpio"). I don't think it made the cut.

Be sure and add your vote in the Feature request form.

Frankly, the reasons for using CF are getting fewer. But, it has the power to use Xquery now (you just need to do a little work) and it is still one of the fastest ways to prototype most any web application.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2006 Nov 08, 2006

Copy link to clipboard

Copied

> This is basic for use with SQL Server 2005, Oracle etc.

Right. So it's the DB's job to process the XQuery statements then. Just
like CF doesn't need to understand the SQL statements in a <cfquery>, nor
would it need to understand and XQuery statements passed in the same
fashion.

Have you actually TRIED

<cfquery name="q" datasource="yourDsn">
xpath query here
</cfquery>

?

This article: http://en.wikipedia.org/wiki/XQuery points to some DataDirect
drivers that might be useful for you.

This one: http://www.w3.org/XML/Query/ has loads of Java resources, which'd
be pretty easy to call natively in CF.

I don't think there's any need to wait around for a native xmlQuery()
function to be implemented in CF.

--
Adam

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 09, 2006 Nov 09, 2006

Copy link to clipboard

Copied

you wrote:
Have you actually TRIED

<cfquery name="q" datasource="yourDsn">
xpath query here
</cfquery>

?
===

Good question. I did. The Xquery contained:

tablename.query ...

The CF compiler did not like the period between tablename and query (query is am Xquery function).

There myaybe someway around it with escape characters, i don't know, so any information is useful. But if the compiler really is expecting SQL structure it might be a problem. Don't know how Cf compiler works.

thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 10, 2006 Nov 10, 2006

Copy link to clipboard

Copied

> Good question. I did. The Xquery contained:
>
> tablename.query ...
>
> The CF compiler did not like the period between tablename and query (query is
> am Xquery function).

Can you post the EXACT <cfquery> block?


> There myaybe someway around it with escape characters, i don't know, so any
> information is useful. But if the compiler really is expecting SQL structure
> it might be a problem. Don't know how Cf compiler works.

All CF does with the contents of a <cfquery/> block is to resolve any CFML
constructs in it (control logic, tags, functions, variables). Then it has
a string. Then it passes the string to the DB driver. From a "DB
instruction" POV, CF does *nothing* with the string.

So I can't see that CF would be choking on the actual xquery statements.

However possibly the DB driver is, as it actually needs to be able to
understand what you're telling it. Did you try one of those DB drivers I
mentioned y/day?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

Thanks everyone for the input. I don't hae time to post a complete info, but I will later if I find a solution or get stuck again.

Points:

When I removed the
"USE DatabaseX" line from the SQL, the problem with the "." character went away. Siince the CF datasource was already pointed at Database X maybe this was redundant information.

RIght now there seems to be a problem with what variable name to use for the return from the database (if there is any) between the cfoutput tags . I can do a straight SQL statement on the same database and name the variable with the Colunm name. However with Xquery this is not working.

It may well be that I need a driver which understands XQuery, as had been sugested.

Thanks again.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

LATEST


Success! I needed to use AS to name the return as a CF variable when using XQuery. For SQL, the Colunm name can be used without being identified

The table is HAFDIR
The column is Article
The root element of the xml is also Article (refered to as /Article below)

the following XQuery statement worked within cfquery:

SELECT
Article.query ('declare default namespace "foobar';
(/Article)')
AS 'thing'
FROM dbo.HAFDIR


The cfoutput section refers to the output as #thing#

e.g.

<cfoutput>
#thing#
</cfoutput>

If I used SQL it would be

SELECT Article
FROM dbo.HAFDIR


<cfoutput>
#Article#
</cfquery>

Thanks for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation