Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Posts
    3

    Unanswered: SQLXML xPath query over .XSD

    Hi All,

    I have a relational hierarchy along the lines of:

    Country
    Parent
    Customer
    Authority
    Cost centre

    System users either belong to Parents or Customers. I'm issuing an xPath restriction, using SQLXML over an .XSD schema:

    "/parent[@parentid='U400410']/customer/authority[@authorityid='U127002']"

    Which returns XML for the particular authority:

    <authority>
    <costcentre>
    ...
    </costcentre>
    </authority>

    Could someone please advise me the xPath syntax which would still enable me to restrict to a particular authority as above, but return XML from the top of the hierarchy downwards, i.e:

    <country>
    <parent>
    <customer>
    <authority>
    <costcentre>
    ...
    </costcentre>
    </authority>
    </customer>
    </parent>
    </country>

    Is this even possible? I would really appreciate any help, since this is the last, and very frustrating, puzzle piece I need to complete. (If it's not possible, alternative approaches would be welcome.)

    Thanks

  2. #2
    Join Date
    Feb 2003
    Location
    Milano, Italy
    Posts
    80
    Hi

    I think you should have to use the "ancestor" or "preceeding" location path. Something like that:

    "/parent[@parentid='U400410']/customer/authority[@authorityid='U127002']/preceeding::*"

    now i don't remember the exact sysntax, anyway if you download the MSXML 4.0 package from MS, that you can use the that help to search for "Axes".

    Hope that this help you.
    Davide

  3. #3
    Join Date
    Feb 2003
    Location
    Milano, Italy
    Posts
    80

  4. #4
    Join Date
    Jul 2003
    Posts
    3

    Red face

    Thanks a lot for the info Davide, but it appears that the current version of SQLXML (3.0) doesn't support axes, as they're termed. If I use:

    '/parent[@parentid='U400410']/customer/authority[@authorityid='U127002']/ancestor::*'

    I get:

    <?MSSQLError HResult="0x80004005" Source="Microsoft XML Extensions to SQL Server" Description="XPath: the ancestor axis is not supported"?>

    If I use:

    '/parent[@parentid='U400410']/customer/authority[@authorityid='U127002']/parent::*'

    I get:

    <?MSSQLError HResult="0x80004005" Source="Microsoft XML Extensions to SQL Server" Description="XPath: the parent axis is not supported on the primary location path"?>

    Bummer! Does anyone know how I can work around this?

  5. #5
    Join Date
    Feb 2003
    Location
    Milano, Italy
    Posts
    80
    Ouch!

    To work around this probabily you have to do it on your own, using MSXML 4.0.

    You may have to write an ASP / ASP.NET pages that takes the XML produced by SQLXML and the process it using MSXML 4.0.

    To do this i'll use .NET that with a few lines of code will allow you to get the result you need.
    Davide Mauri
    http://www.davidemauri.it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •