8 Replies Latest reply on Nov 15, 2006 9:58 AM by BAEman

    XQuery support

    BAEman
      Does CFMX7 support XQuery?
        • 1. Re: XQuery support
          MikerRoo Level 1
          Not yet, not directly.

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

          Figure it out and post some code!
          • 2. Re: XQuery support
            BAEman Level 1


            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?
            • 3. Re: XQuery support
              MikerRoo Level 1
              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.
              • 4. Re: XQuery support
                Level 7
                > 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
                • 5. Re: XQuery support
                  BAEman Level 1
                  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.

                  • 6. Re: XQuery support
                    Level 7
                    > 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
                    • 7. Re: XQuery support
                      BAEman Level 1
                      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.


                      • 8. Re: XQuery support
                        BAEman Level 1


                        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.